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

Compare commits

..

214 Commits

Author SHA1 Message Date
riking
13f0f396d7 Rearrange checks in PartyInviteCommand 2013-10-28 13:31:22 -07:00
riking
31e04a2d91 ToggleCommand shouldn't hit the database 2013-10-28 13:30:43 -07:00
riking
2fcd3904dc In Kraken command, use getPlayer(name, true) and a null-check 2013-10-28 13:20:26 -07:00
riking
92fa2782d0 Have PtpCommand use getPlayerExact to check for offline 2013-10-28 13:12:57 -07:00
riking
eb10db5b06 Make PartyJoinCommand use PartyManager directly for lookup 2013-10-28 13:04:48 -07: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
497 changed files with 8333 additions and 9317 deletions

View File

@@ -7,7 +7,16 @@ Key:
! Change
- Removal
Version 1.4.07-dev
Version 1.4.08-dev
+ Added the possibility to gain experience when using Fishing "Shake"
= Fixed IllegalArgumentException caused by an empty Fishing treasure category
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"
@@ -22,6 +31,16 @@ Version 1.4.07-dev
+ 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
@@ -32,22 +51,42 @@ Version 1.4.07-dev
= 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 mode can now be toggled for each skill individually
! 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
! Slightly improved update checker feedback
! 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

View File

@@ -2,10 +2,10 @@
## The RPG lovers mod
### 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
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds thirteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Additionally, when run in conjuction with SpoutPlugin, mcMMO also has a custom XP bar to allow for easy tracking of progress towards leveling up. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
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.
## About the Team
@@ -29,15 +29,16 @@ mcMMO is currently developed by a team of individuals from all over the world.
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)]
(https://github.com/riking)
## Compiling
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:
* Spout API
* JUnit
* EMetrics
* Bukkit

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

57
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.07-beta1</version>
<version>1.4.08-dev1</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -22,38 +22,6 @@
<include>.jenkins</include>
</includes>
</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>
<targetPath>com/gmail/nossr50/locale</targetPath>
<filtering>true</filtering>
@@ -62,6 +30,14 @@
<include>locale*.properties</include>
</includes>
</resource>
<resource>
<targetPath>mods</targetPath>
<filtering>true</filtering>
<directory>${basedir}/src/main/resources/mods</directory>
<includes>
<include>*.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
@@ -132,10 +108,6 @@
<id>bukkit-repo</id>
<url>http://repo.bukkit.org/content/groups/public/</url>
</repository>
<repository>
<id>spout-repo</id>
<url>http://nexus.spout.org/content/groups/public/</url>
</repository>
<repository>
<id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url>
@@ -149,13 +121,6 @@
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.getspout</groupId>
<artifactId>spoutplugin</artifactId>
<version>LATEST</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit-dep</artifactId>
@@ -178,7 +143,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<ciManagement>
<system>Jenkins</system>
<url>ci.mcmmo.org</url>
<system>Jenkins</system>
<url>http://ci.ecocitycraft.com/job/mcMMO</url>
</ciManagement>
</project>

View File

@@ -48,6 +48,11 @@ public final class ExperienceAPI {
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.
* </br>
@@ -59,10 +64,15 @@ public final class ExperienceAPI {
*
* @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);
}
@Deprecated
public static void addRawXPOffline(String playerName, String skillType, int XP) {
addRawXPOffline(playerName, skillType, (float) XP);
}
/**
* Adds raw XP to an offline player.
* </br>
@@ -75,8 +85,8 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
* @throws InvalidPlayerException if the given player does not exist in the database
*/
public static void addRawXPOffline(String playerName, String skillType, int XP) {
addOfflineXP(playerName, getSkillType(skillType), XP);
public static void addRawXPOffline(String playerName, String skillType, float XP) {
addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
}
/**
@@ -404,7 +414,7 @@ public final class ExperienceAPI {
int powerLevel = 0;
PlayerProfile profile = getOfflineProfile(playerName);
for (SkillType type : SkillType.nonChildSkills()) {
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
powerLevel += profile.getSkillLevel(type);
}
@@ -451,7 +461,7 @@ public final class ExperienceAPI {
* @return the position on the leaderboard
*/
public static int getPlayerRankSkill(String playerName, String skillType) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType).toString());
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(getNonChildSkillType(skillType));
}
@@ -467,7 +477,7 @@ public final class ExperienceAPI {
* @return the position on the power level leaderboard
*/
public static int getPlayerRankOverall(String playerName) {
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get("ALL");
return mcMMO.getDatabaseManager().readRank(getOfflineProfile(playerName).getPlayerName()).get(null);
}
/**

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

@@ -27,7 +27,7 @@ public class PartyChatManager extends ChatManager {
@Override
protected void sendMessage() {
if (Config.getInstance().getPartyChatColorLeaderName() && senderName.equalsIgnoreCase(party.getLeader())) {
message = message.replaceAll(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
message = message.replaceFirst(displayName, ChatColor.GOLD + displayName + ChatColor.RESET);
}
for (Player member : party.getOnlineMembers()) {

View File

@@ -11,11 +11,10 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class KrakenCommand implements TabExecutor {
@@ -41,10 +40,10 @@ public class KrakenCommand implements TabExecutor {
return true;
}
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(args[0], true);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
if (mcMMOPlayer == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}

View File

@@ -24,6 +24,6 @@ public class McabilityCommand extends ToggleCommand {
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage("Ability use has been toggled for " + player.getName()); // TODO: Localize
sender.sendMessage(LocaleLoader.getString("Commands.Ability.Toggle"));
}
}

View File

@@ -24,6 +24,6 @@ public class McgodCommand extends ToggleCommand {
@Override
protected void sendSuccessMessage(CommandSender sender) {
sender.sendMessage("God mode has been toggled for " + player.getName()); // TODO: Localize
sender.sendMessage(LocaleLoader.getString("Commands.GodMode.Success"));
}
}

View File

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

View File

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

@@ -12,9 +12,9 @@ import org.bukkit.util.StringUtil;
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.player.UserManager;
import com.google.common.collect.ImmutableList;
public class MobhealthCommand implements TabExecutor {
@@ -44,11 +44,11 @@ public class MobhealthCommand implements TabExecutor {
try {
MobHealthbarType type = MobHealthbarType.valueOf(args[0].toUpperCase().trim());
playerProfile.setMobHealthbarType(type);
sender.sendMessage("Display type changed to: " + type); //TODO: Localize
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Changed." + type.name()));
return true;
}
catch (IllegalArgumentException ex) {
sender.sendMessage("Invalid type!"); //TODO: Localize
sender.sendMessage(LocaleLoader.getString("Commands.Healthbars.Invalid"));
return true;
}

View File

@@ -11,10 +11,9 @@ import org.bukkit.entity.Player;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public abstract class ToggleCommand implements TabExecutor {
@@ -46,19 +45,15 @@ public abstract class ToggleCommand implements TabExecutor {
return true;
}
String playerName = Misc.getMatchedPlayerName(args[0]);
mcMMOPlayer = UserManager.getPlayer(playerName);
mcMMOPlayer = UserManager.getPlayer(args[0], true);
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
if (mcMMOPlayer == null) {
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
player = mcMMOPlayer.getPlayer();
if (CommandUtils.isOffline(sender, player)) {
return true;
}
applyCommandAction();
sendSuccessMessage(sender);
return true;

View File

@@ -22,7 +22,7 @@ public class ConvertDatabaseCommand implements CommandExecutor {
DatabaseType previousType = DatabaseType.getDatabaseType(args[1]);
DatabaseType newType = mcMMO.getDatabaseManager().getDatabaseType();
if ((newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1])) || previousType == newType) {
if (previousType == newType || (newType == DatabaseType.CUSTOM && DatabaseManagerFactory.getCustomDatabaseManagerClass().getSimpleName().equalsIgnoreCase(args[1]))) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.Same", newType.toString()));
return true;
}
@@ -39,17 +39,12 @@ public class ConvertDatabaseCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}
catch (Exception e) {
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
try {
oldDatabase = DatabaseManagerFactory.createCustomDatabaseManager((Class<? extends DatabaseManager>) clazz);
}
catch (Throwable t) {
sender.sendMessage("An error occurred during the conversion process."); // TODO: Localize
catch (Throwable e) {
e.printStackTrace();
sender.sendMessage(LocaleLoader.getString("Commands.mcconvert.Database.InvalidType", args[1]));
return true;
}
}

View File

@@ -45,7 +45,7 @@ public class McconvertCommand implements TabExecutor {
}
// Custom stuff
databaseTypes.remove(DatabaseType.CUSTOM);
databaseTypes.remove(DatabaseType.CUSTOM.toString());
if (mcMMO.getDatabaseManager().getDatabaseType() == DatabaseType.CUSTOM) {
databaseTypes.add(DatabaseManagerFactory.getCustomDatabaseManagerClass().getName());

View File

@@ -2,12 +2,10 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AddlevelsCommand extends ExperienceCommand {
@Override
@@ -22,11 +20,14 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.addLevels(skill, value);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value));
if (player == null) {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, true);
}
@Override
@@ -36,6 +37,6 @@ public class AddlevelsCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
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

@@ -5,7 +5,6 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class AddxpCommand extends ExperienceCommand {
@Override
@@ -35,6 +34,6 @@ public class AddxpCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, SkillUtils.getSkillName(skill)));
player.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", value, skill.getName()));
}
}

View File

@@ -18,7 +18,6 @@ import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -67,7 +66,7 @@ public abstract class ExperienceCommand implements TabExecutor {
}
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
mcMMOPlayer = UserManager.getPlayer(playerName, true);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -149,7 +148,7 @@ public abstract class ExperienceCommand implements TabExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", playerName));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillUtils.getSkillName(skill), playerName));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", skill.getName(), playerName));
}
}

View File

@@ -2,13 +2,10 @@ package com.gmail.nossr50.commands.experience;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
public class MmoeditCommand extends ExperienceCommand {
@Override
@@ -23,20 +20,16 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handleCommand(SkillType skill) {
int skillLevel = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, value);
if (player == null) {
if (player == null || value == skillLevel) {
return;
}
int skillLevel = profile.getSkillLevel(skill);
if (value > skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelUpEvent(player, skill, value - skillLevel));
}
else if (value < skillLevel) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, skillLevel - value));
}
EventUtils.handleLevelChangeEvent(player, skill, value, xpRemoved, value > skillLevel);
}
@Override
@@ -46,6 +39,6 @@ public class MmoeditCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
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

@@ -6,13 +6,12 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelDownEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillresetCommand extends ExperienceCommand {
private CommandSender sender;
@@ -103,11 +102,16 @@ public class SkillresetCommand extends ExperienceCommand {
return;
}
int levelsRemoved = profile.getSkillLevel(skill);
float xpRemoved = profile.getSkillXpLevelRaw(skill);
profile.modifySkill(skill, 0);
if (player != null) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerLevelDownEvent(player, skill, profile.getSkillLevel(skill)));
if (player == null) {
return;
}
EventUtils.handleLevelChangeEvent(player, skill, levelsRemoved, xpRemoved, false);
}
@Override
@@ -117,6 +121,6 @@ public class SkillresetCommand extends ExperienceCommand {
@Override
protected void handlePlayerMessageSkill() {
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", SkillUtils.getSkillName(skill)));
player.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skill.getName()));
}
}

View File

@@ -50,12 +50,12 @@ public class HardcoreCommand extends HardcoreModeCommand {
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreStatLossEnabled(skillType, enable);
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreStatLossEnabled(enable);
}
}
else {
Config.getInstance().setHardcoreStatLossEnabled(SkillType.getSkill(skill), enable);
SkillType.getSkill(skill).setHardcoreStatLossEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), skill));

View File

@@ -48,16 +48,16 @@ public class VampirismCommand extends HardcoreModeCommand {
sender.sendMessage(LocaleLoader.getString("Hardcore.Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
}
private void toggle(boolean enabled) {
private void toggle(boolean enable) {
if (skill.equalsIgnoreCase("ALL")) {
for (SkillType skillType : SkillType.nonChildSkills()) {
Config.getInstance().setHardcoreVampirismEnabled(skillType, enabled);
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skillType.setHardcoreVampirismEnabled(enable);
}
}
else {
Config.getInstance().setHardcoreVampirismEnabled(SkillType.getSkill(skill), enabled);
SkillType.getSkill(skill).setHardcoreVampirismEnabled(enable);
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enabled ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), skill));
}
}

View File

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

View File

@@ -9,31 +9,26 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyJoinCommand implements CommandExecutor {
private McMMOPlayer mcMMOTarget;
private Player target;
private Party targetParty;
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party targetParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
case 3:
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
// Verify target exists and is in a different party than the player
if (!canJoinParty(sender, args[1])) {
return true;
}
mcMMOPlayer = UserManager.getPlayer((Player) sender);
player = mcMMOPlayer.getPlayer();
String password = getPassword(args);
// Make sure party passwords match
@@ -67,25 +62,21 @@ public class PartyJoinCommand implements CommandExecutor {
}
private boolean canJoinParty(CommandSender sender, String targetName) {
targetName = Misc.getMatchedPlayerName(targetName);
mcMMOTarget = UserManager.getPlayer(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
// Short-circuit for joining your own party
if (sender.getName().equalsIgnoreCase(targetName)) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}
target = mcMMOTarget.getPlayer();
targetParty = PartyManager.getPlayerParty(targetName);
if (!mcMMOTarget.inParty()) {
if (targetParty == null) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return false;
}
player = (Player) sender;
mcMMOPlayer = UserManager.getPlayer(player);
targetParty = mcMMOTarget.getParty();
if (player.equals(target) || (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty))) {
// Can't join your own party
if (mcMMOPlayer.inParty() && mcMMOPlayer.getParty().equals(targetParty)) {
sender.sendMessage(LocaleLoader.getString("Party.Join.Self"));
return false;
}

View File

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

View File

@@ -38,7 +38,7 @@ public class PtpAcceptCommand implements CommandExecutor {
Player target = mcMMOPlayer.getPtpRequest();
mcMMOPlayer.removePtpRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
if (!PtpCommand.canTeleport(player, target.getName())) {
return true;
}

View File

@@ -14,10 +14,10 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.items.TeleportationWarmup;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
@@ -88,7 +88,7 @@ public class PtpCommand implements TabExecutor {
}
}
sendTeleportRequest(sender, player, Misc.getMatchedPlayerName(args[0]));
sendTeleportRequest(player, Misc.getMatchedPlayerName(args[0]));
return true;
default:
@@ -113,8 +113,8 @@ public class PtpCommand implements TabExecutor {
}
}
private void sendTeleportRequest(CommandSender sender, Player player, String targetName) {
if (!canTeleport(sender, player, targetName)) {
private void sendTeleportRequest(Player player, String targetName) {
if (!canTeleport(player, targetName)) {
return;
}
@@ -132,20 +132,21 @@ public class PtpCommand implements TabExecutor {
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", Config.getInstance().getPTPCommandTimeout()));
}
protected static boolean canTeleport(CommandSender sender, Player player, String targetName) {
mcMMOTarget = UserManager.getPlayer(targetName);
protected static boolean canTeleport(Player player, String targetName) {
target = mcMMO.p.getServer().getPlayerExact(targetName);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
if (target == null) {
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
return false;
}
target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
mcMMOTarget = UserManager.getPlayer(target);
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
@@ -177,25 +178,7 @@ public class PtpCommand implements TabExecutor {
new TeleportationWarmup(mcMMOPlayer, mcMMOTarget).runTaskLater(mcMMO.p, 20 * warmup);
}
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.actualizePtpLastUse();
}
}

View File

@@ -29,10 +29,6 @@ public class InspectCommand implements TabExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
ScoreboardManager.setupPlayerScoreboard(sender.getName());
}
String playerName = Misc.getMatchedPlayerName(args[0]);
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
@@ -44,30 +40,31 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
return true;
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
for (SkillType skill : SkillType.GATHERING_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
for (SkillType skill : SkillType.COMBAT_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
for (SkillType skill : SkillType.MISC_SKILLS) {
sender.sendMessage(CommandUtils.displaySkill(profile, skill));
}
}
else {
Player target = mcMMOPlayer.getPlayer();
@@ -82,9 +79,12 @@ public class InspectCommand implements TabExecutor {
return true;
}
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
return true;
if (sender instanceof Player && Config.getInstance().getInspectUseBoard()) {
ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!Config.getInstance().getInspectUseChat()) {
return true;
}
}
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));

View File

@@ -0,0 +1,69 @@
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.NORMAL_ABILITIES) {
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,13 +13,12 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList;
public class McrankCommand implements TabExecutor {
@@ -36,13 +35,7 @@ public class McrankCommand implements TabExecutor {
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;
@@ -56,9 +49,10 @@ public class McrankCommand implements TabExecutor {
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName, true);
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;
}
}
@@ -66,13 +60,7 @@ public class McrankCommand implements TabExecutor {
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;
default:
@@ -92,6 +80,20 @@ public class McrankCommand implements TabExecutor {
}
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,7 +8,6 @@ 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.locale.LocaleLoader;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
@@ -26,28 +25,29 @@ public class McstatsCommand implements TabExecutor {
switch (args.length) {
case 0:
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
if (Config.getInstance().getMcstatsScoreboardsEnabled()) {
ScoreboardManager.setupPlayerScoreboard(player.getName());
ScoreboardManager.enablePlayerStatsScoreboard(mcMMOPlayer);
if (Config.getInstance().getStatsUseBoard()) {
ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!Config.getInstance().getStatsUseChat()) {
return true;
}
}
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
CommandUtils.printGatheringSkills(player);
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
}
else {
player.sendMessage(LocaleLoader.getString("Stats.Own.Stats"));
player.sendMessage(LocaleLoader.getString("mcMMO.NoSkillNote"));
CommandUtils.printGatheringSkills(player);
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", UserManager.getPlayer(player).getPowerLevel()));
}
return true;

View File

@@ -11,36 +11,40 @@ import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class MctopCommand implements TabExecutor {
private SkillType skill;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
SkillType skill = null;
switch (args.length) {
case 0:
display(1, "ALL", sender, command);
display(1, skill, sender, command);
return true;
case 1:
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;
}
if (!extractSkill(sender, args[0])) {
skill = extractSkill(sender, args[0]);
if (skill == null) {
return true;
}
display(1, skill.toString(), sender, command);
display(1, skill, sender, command);
return true;
case 2:
@@ -48,11 +52,13 @@ public class MctopCommand implements TabExecutor {
return true;
}
if (!extractSkill(sender, args[0])) {
skill = extractSkill(sender, args[0]);
if (skill == null) {
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;
default:
@@ -70,35 +76,44 @@ public class MctopCommand implements TabExecutor {
}
}
private void display(int page, String skill, CommandSender sender, Command command) {
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, this.skill)) {
private void display(int page, SkillType skill, CommandSender sender, Command command) {
if (skill != null && !Permissions.mctop(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (sender instanceof Player && Config.getInstance().getMctopScoreboardEnabled()) {
ScoreboardManager.enableGlobalStatsScoreboard((Player) sender, skill, page);
}
else {
display(page, skill, sender);
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();
}
display(page, skill, sender);
}
private void display(int page, String query, CommandSender sender) {
new MctopCommandAsyncTask(page, query, sender).runTaskAsynchronously(mcMMO.p);
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 boolean extractSkill(CommandSender sender, String skillName) {
private SkillType extractSkill(CommandSender sender, String skillName) {
if (CommandUtils.isInvalidSkill(sender, skillName)) {
return false;
return null;
}
skill = SkillType.getSkill(skillName);
SkillType skill = SkillType.getSkill(skillName);
if (CommandUtils.isChildSkill(sender, skill)) {
return false;
return null;
}
return true;
return skill;
}
}

View File

@@ -82,15 +82,15 @@ public class AcrobaticsCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", rollChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", rollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", rollChanceLucky) : ""));
}
if (canGracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", gracefulRollChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.GraceChance", gracefulRollChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", gracefulRollChanceLucky) : ""));
}
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dodgeChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", dodgeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dodgeChanceLucky) : ""));
}
}
}

View File

@@ -84,11 +84,11 @@ public class ArcheryCommand extends SkillCommand {
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", dazeChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", dazeChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", dazeChanceLucky) : ""));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", retrieveChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", retrieveChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", retrieveChanceLucky) : ""));
}
}
}

View File

@@ -109,11 +109,11 @@ public class AxesCommand extends SkillCommand {
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", critChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", critChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", critChanceLucky) : ""));
}
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", skullSplitterLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", skullSplitterLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", skullSplitterLengthEndurance) : ""));
}
}
}

View File

@@ -57,7 +57,7 @@ public class ExcavationCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", gigaDrillBreakerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", gigaDrillBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", gigaDrillBreakerLengthEndurance) : ""));
}
}
}

View File

@@ -1,25 +1,36 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.Location;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String magicChance;
private String magicChanceLucky;
private String chanceRaining = "";
private String shakeChance;
private String shakeChanceLucky;
private int fishermansDietRank;
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 canMagicHunt;
private boolean canShake;
@@ -38,16 +49,24 @@ public class FishingCommand extends SkillCommand {
// TREASURE HUNTER
if (canTreasureHunt) {
lootTier = mcMMOPlayer.getFishingManager().getLootTier();
double enchantChance = lootTier * AdvancedConfig.getInstance().getFishingMagicMultiplier();
if (isStorming) {
chanceRaining = LocaleLoader.getString("Fishing.Chance.Raining");
enchantChance *= 1.1D;
}
// Item drop rates
trapTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.TRAP))[0];
commonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.COMMON))[0];
uncommonTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.UNCOMMON))[0];
rareTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RARE))[0];
epicTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.EPIC))[0];
legendaryTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.LEGENDARY))[0];
recordTreasure = calculateAbilityDisplayValues(TreasureConfig.getInstance().getItemDropRate(lootTier, Rarity.RECORD))[0];
String[] treasureHunterStrings = calculateAbilityDisplayValues(enchantChance);
magicChance = treasureHunterStrings[0];
magicChanceLucky = treasureHunterStrings[1];
// Magic hunter drop rates
double commonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.COMMON);
double uncommonEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.UNCOMMON);
double rareEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.RARE);
double epicEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.EPIC);
double legendaryEnchantment = TreasureConfig.getInstance().getEnchantmentDropRate(lootTier, Rarity.LEGENDARY);
magicChance = calculateAbilityDisplayValues(commonEnchantment + uncommonEnchantment + rareEnchantment + epicEnchantment + legendaryEnchantment)[0];
}
// SHAKE
@@ -64,15 +83,17 @@ public class FishingCommand extends SkillCommand {
// MASTER ANGLER
if (canMasterAngler) {
double rawBiteChance = ((Math.max((skillValue / 200.0), 1.0)) / (isStorming ? 300 : 500));
Biome biome = player.getLocation().getBlock().getBiome();
double rawBiteChance = 1.0 / (isStorming ? 300 : 500);
Location location = (mcMMOPlayer.getHookLocation() != null) ? mcMMOPlayer.getHookLocation() : player.getLocation();
Biome biome = location.getBlock().getBiome();
if (biome == Biome.RIVER || biome == Biome.OCEAN) {
rawBiteChance = rawBiteChance * 2.0;
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBiomeModifier();
}
if (player.isInsideVehicle() && player.getVehicle().getType() == EntityType.BOAT) {
rawBiteChance = rawBiteChance * 2.0;
rawBiteChance = rawBiteChance * AdvancedConfig.getInstance().getMasterAnglerBoatModifier();
}
biteChance = calculateAbilityDisplayValues(rawBiteChance * 100.0)[0];
@@ -106,20 +127,20 @@ public class FishingCommand extends SkillCommand {
player.sendMessage(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 (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
}
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.8"), LocaleLoader.getString("Fishing.Effect.9")));
}
if (canIceFish) {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Fishing.Effect.10"), LocaleLoader.getString("Fishing.Effect.11")));
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")));
}
}
@@ -130,31 +151,13 @@ public class FishingCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canMasterAngler) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", lootTier, Tier.EIGHT.toNumerical()));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.DropRate", trapTreasure, commonTreasure, uncommonTreasure, rareTreasure, epicTreasure, legendaryTreasure, recordTreasure));
}
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", magicChance) + chanceRaining + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", magicChanceLucky) : ""));
}
if (canShake) {
int unlockLevel = AdvancedConfig.getInstance().getShakeUnlockLevel();
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) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.TH.MagicRate", magicChance));
}
if (canIceFish) {
@@ -167,5 +170,31 @@ public class FishingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.IceFishing"));
}
}
if (canMasterAngler) {
int unlockLevel = AdvancedConfig.getInstance().getMasterAnglerUnlockLevel();
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Fishing.Ability.Locked.2", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Chance", biteChance));
}
}
if (canShake) {
int unlockLevel = AdvancedConfig.getInstance().getFishingTierLevel(Tier.ONE);
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) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.FD", fishermansDietRank));
}
}
}

View File

@@ -135,11 +135,11 @@ public class HerbalismCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", greenTerraLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", greenTerraLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", greenTerraLengthEndurance) : ""));
}
if (canGreenThumbBlocks || canGreenThumbPlants) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", greenThumbChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", greenThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", greenThumbChanceLucky) : ""));
}
if (canGreenThumbPlants) {
@@ -151,15 +151,15 @@ public class HerbalismCommand extends SkillCommand {
}
if (hasHylianLuck) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", hylianLuckChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.HylianLuck", hylianLuckChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", hylianLuckChanceLucky) : ""));
}
if (canShroomThumb) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", shroomThumbChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.ShroomThumb.Chance", shroomThumbChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", shroomThumbChanceLucky) : ""));
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
}
}

View File

@@ -3,6 +3,7 @@ package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.util.Permissions;
@@ -106,26 +107,26 @@ public class MiningCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", superBreakerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", superBreakerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", superBreakerLengthEndurance) : ""));
}
if (canBlast) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank1();
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.ONE);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.0", unlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", blastMiningRank, Tier.EIGHT.toNumerical(), LocaleLoader.getString("Mining.Blast.Effect", oreBonus, debrisReduction, bonusTNTDrops)));
}
}
if (canBiggerBombs) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank2();
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
@@ -136,7 +137,7 @@ public class MiningCommand extends SkillCommand {
}
if (canDemoExpert) {
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRank4();
int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));

View File

@@ -6,9 +6,10 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
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.RepairManager;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
public class RepairCommand extends SkillCommand {
@@ -41,10 +42,10 @@ public class RepairCommand extends SkillCommand {
@Override
protected void dataCalculations() {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE.getId());
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE.getId());
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE.getId());
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE.getId());
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
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
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
@@ -139,13 +140,13 @@ public class RepairCommand extends SkillCommand {
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", superRepairChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
}
if (canArcaneForge) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank()));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
if (ArcaneForging.arcaneForgingEnchantLoss) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));

View File

@@ -23,7 +23,6 @@ import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -46,7 +45,7 @@ public abstract class SkillCommand implements TabExecutor {
public SkillCommand(SkillType skill) {
this.skill = skill;
skillName = SkillUtils.getSkillName(skill);
skillName = skill.getName();
skillGuideCommand = new SkillGuideCommand(skill);
}
@@ -70,17 +69,14 @@ public abstract class SkillCommand implements TabExecutor {
permissionsCheck();
dataCalculations();
if (Config.getInstance().getSkillUseBoard()) {
ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
}
if (!skill.isChildSkill()) {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", LocaleLoader.getString("Commands.XPGain." + StringUtils.getCapitalized(skill.toString()))));
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)));
}
player.sendMessage(LocaleLoader.getString("Effects.Level", (int) skillValue, profile.getSkillXpLevel(skill), profile.getXpToLevel(skill)));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.Header", skillName + " " + LocaleLoader.getString("Skills.Child")));
@@ -91,7 +87,7 @@ public abstract class SkillCommand implements TabExecutor {
Set<SkillType> parents = FamilyTree.getParents(skill);
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", profile.getSkillLevel(parent), profile.getSkillXpLevel(parent), profile.getXpToLevel(parent)));
}
}
@@ -143,7 +139,7 @@ public abstract class SkillCommand implements TabExecutor {
}
protected String[] calculateLengthDisplayValues() {
int maxLength = skill.getAbility().getMaxTicks();
int maxLength = skill.getAbility().getMaxLength();
int length = 2 + (int) (skillValue / AdvancedConfig.getInstance().getAbilityLength());
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
@@ -157,7 +153,7 @@ public abstract class SkillCommand implements TabExecutor {
protected void luckyEffectsDisplay() {
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)));
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.Lucky.Name"), LocaleLoader.getString("Perks.Lucky.Desc", skillName)));
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.Arrays;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@@ -9,17 +10,16 @@ import org.bukkit.command.CommandSender;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
public class SkillGuideCommand implements CommandExecutor {
private String header;
private String[] guide;
private ArrayList<String> guide;
private String invalidPage;
public SkillGuideCommand(SkillType skillType) {
header = LocaleLoader.getString("Guides.Header", SkillUtils.getSkillName(skillType));
guide = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.toString())).split("\n");
header = LocaleLoader.getString("Guides.Header", skillType.getName());
guide = getGuide(skillType);
invalidPage = LocaleLoader.getString("Guides.Page.Invalid");
}
@@ -59,7 +59,7 @@ public class SkillGuideCommand implements CommandExecutor {
}
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) {
@@ -76,15 +76,38 @@ public class SkillGuideCommand implements CommandExecutor {
// Add targeted strings
while (allStrings.size() < 9) {
if (pageIndexStart + allStrings.size() > guide.length) {
if (pageIndexStart + allStrings.size() > guide.size()) {
allStrings.add("");
}
else {
allStrings.add(guide[pageIndexStart + (allStrings.size() - 1)]);
allStrings.add(guide.get(pageIndexStart + (allStrings.size() - 1)));
}
}
allStrings.add("Page " + pagenum + " of " + getTotalPageNumber());
return allStrings;
}
private ArrayList<String> getGuide(SkillType skillType) {
ArrayList<String> guide = new ArrayList<String>();
for (int i = 0; i < 10; i++) {
String[] section = LocaleLoader.getString("Guides." + StringUtils.getCapitalized(skillType.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

@@ -4,6 +4,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.smelting.Smelting;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.Permissions;
public class SmeltingCommand extends SkillCommand {
@@ -90,11 +91,11 @@ public class SmeltingCommand extends SkillCommand {
}
if (canSecondSmelt) {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", secondSmeltChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Smelting.Ability.SecondSmelt", secondSmeltChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", secondSmeltChanceLucky) : ""));
}
if (canVanillaXPBoost) {
int unlockLevel = AdvancedConfig.getInstance().getSmeltingVanillaXPBoostRank1Level();
int unlockLevel = AdvancedConfig.getInstance().getSmeltingRankLevel(Tier.ONE);
if (skillValue < unlockLevel) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.0", unlockLevel)));
@@ -109,7 +110,7 @@ public class SmeltingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Smelting.Ability.Locked.1", Smelting.fluxMiningUnlockLevel)));
}
else {
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", fluxMiningChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Smelting.Ability.FluxMining", fluxMiningChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", fluxMiningChanceLucky) : ""));
}
}
}

View File

@@ -86,17 +86,17 @@ public class SwordsCommand extends SkillCommand {
@Override
protected void statsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", counterAttackChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", counterAttackChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", counterAttackChanceLucky) : ""));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", bleedLength));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", bleedChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", bleedChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", bleedChanceLucky) : ""));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", serratedStrikesLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", serratedStrikesLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", serratedStrikesLengthEndurance) : ""));
}
}
}

View File

@@ -38,7 +38,7 @@ public class TamingCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canBeastLore = Permissions.beastLore(player);
canCallWild = Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.environmentallyAware(player);
canFastFood = Permissions.fastFoodService(player);
canGore = Permissions.gore(player);
@@ -93,6 +93,7 @@ public class TamingCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13")));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", Config.getInstance().getTamingCOTWOcelotCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", Config.getInstance().getTamingCOTWWolfCost()));
player.sendMessage(LocaleLoader.getString("Taming.Effect.20", Config.getInstance().getTamingCOTWHorseCost()));
}
}
@@ -158,7 +159,7 @@ public class TamingCommand extends SkillCommand {
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", goreChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", goreChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", goreChanceLucky) : ""));
}
}
}

View File

@@ -113,19 +113,19 @@ public class UnarmedCommand extends SkillCommand {
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", deflectChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", deflectChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", deflectChanceLucky) : ""));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", disarmChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", disarmChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", disarmChanceLucky) : ""));
}
if (canIronGrip) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", ironGripChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.IronGrip", ironGripChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", ironGripChanceLucky) : ""));
}
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", berserkLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", berserkLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", berserkLengthEndurance) : ""));
}
}
}

View File

@@ -85,11 +85,11 @@ public class WoodcuttingCommand extends SkillCommand {
}
if (canDoubleDrop) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.lucky.bonus", doubleDropChanceLucky) : ""));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", doubleDropChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", doubleDropChanceLucky) : ""));
}
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.activationtime.bonus", treeFellerLengthEndurance) : ""));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", treeFellerLength) + (hasEndurance ? LocaleLoader.getString("Perks.ActivationTime.Bonus", treeFellerLengthEndurance) : ""));
}
}
}

View File

@@ -1,58 +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,90 +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"));
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -63,7 +63,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
output = output.replace(" ", " ");
// 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);
}
@@ -90,7 +90,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
// Dump to the new one
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));
}
}

View File

@@ -45,24 +45,44 @@ public class Config extends AutoUpdateConfigLoader {
}
/* Scoreboards */
if (getMcrankScoreboardTime() != -1 && getMcrankScoreboardTime() <= 0) {
reason.add("Scoreboards.Mcrank.Display_Time should be greater than 0 or -1!");
if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!");
}
if (getMcstatsScoreboardTime() != -1 && getMcstatsScoreboardTime() <= 0) {
reason.add("Scoreboards.Mcstats.Display_Time should be greater than 0 or -1!");
if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) {
reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!");
}
if (getMctopScoreboardTime() != -1 && getMctopScoreboardTime() <= 0) {
reason.add("Scoreboards.Mctop.Display_Time should be greater than 0 or -1!");
if (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("Scoreboards.Inspect.Display_Time should be greater than 0 or -1!");
reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!");
}
if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) {
reason.add("Scoreboards.Skillname.Display_Time should be greater than 0 or -1!");
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 */
@@ -75,12 +95,12 @@ public class Config extends AutoUpdateConfigLoader {
}
/* Hardcore Mode */
if (getHardcoreDeathStatPenaltyPercentage() < 1 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 1 to 100!");
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
reason.add("Hardcore.Death_Stat_Loss.Penalty_Percentage only accepts values from 0.01 to 100!");
}
if (getHardcoreVampirismStatLeechPercentage() < 1 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 1 to 100!");
if (getHardcoreVampirismStatLeechPercentage() < 0.01 || getHardcoreVampirismStatLeechPercentage() > 100) {
reason.add("Hardcore.Vampirism.Leech_Percentage only accepts values from 0.01 to 100!");
}
/* Items */
@@ -92,8 +112,8 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Items.Chimaera_Wing.Recipe_Cost only accepts values from 1 to 64!");
}
if (getChimaeraItemId() < 1) {
reason.add("Items.Chimaera_Wing.Item_ID should be at least 1!");
if (getChimaeraItem() == null) {
reason.add("Items.Chimaera_Wing.Item_Name is invalid!");
}
/* Particles */
@@ -135,21 +155,20 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getDetonatorItemID() < 1) {
reason.add("Skills.Mining.Detonator_ID should be at least 1!");
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
if (getRepairAnvilId() < 1) {
reason.add("Skills.Repair.Anvil_ID should be at least 1!");
if (getRepairAnvilMaterial() == null) {
reason.add("Skills.Repair.Anvil_Type is invalid!!");
}
if (getSalvageAnvilId() < 1) {
reason.add("Skills.Repair.Salvage_Anvil_ID should be at least 1!");
if (getSalvageAnvilMaterial() == null) {
reason.add("Skills.Repair.Salvage_Anvil_Type is invalid!");
}
if (getRepairAnvilId() == getSalvageAnvilId()) {
reason.add("Cannot use the same item ID for Repair and Salvage anvils!");
if (getRepairAnvilMaterial() == getSalvageAnvilMaterial()) {
reason.add("Cannot use the same item for Repair and Salvage anvils!");
}
if (getTamingCOTWWolfCost() < 1) {
@@ -191,12 +210,14 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getConfigOverwriteEnabled() { return config.getBoolean("General.Config_Update_Overwrite", true); }
public String getPartyChatPrefix() { return config.getString("Commands.p.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
public boolean getPartyChatColorLeaderName() { return config.getBoolean("Commands.p.Gold_Leader_Name", true); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public String getPartyChatPrefix() { return config.getString("Commands.partychat.Chat_Prefix_Format", "[[GREEN]]([[WHITE]]{0}[[GREEN]])"); }
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.a.Chat_Prefix_Format", "[[AQUA]][[[WHITE]]{0}[[AQUA]]]"); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.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); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
@@ -211,22 +232,35 @@ public class Config extends AutoUpdateConfigLoader {
public int getMobHealthbarTime() { return config.getInt("Mob_Healthbar.Display_Time", 3); }
/* Scoreboards */
public boolean getMcrankScoreboardEnabled() { return config.getBoolean("Scoreboards.Mcrank.Use", true); }
public int getMcrankScoreboardTime() { return config.getInt("Scoreboards.Mcrank.Display_Time", 10); }
public boolean getRankUseChat() { return config.getBoolean("Scoreboard.Types.Rank.Print", false); }
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 int getMcstatsScoreboardTime() { return config.getInt("Scoreboards.Mcstats.Display_Time", 10); }
public boolean getTopUseChat() { return config.getBoolean("Scoreboard.Types.Top.Print", true); }
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 int getMctopScoreboardTime() { return config.getInt("Scoreboards.Mctop.Display_Time", 10); }
public boolean getStatsUseChat() { return config.getBoolean("Scoreboard.Types.Stats.Print", true); }
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 int getInspectScoreboardTime() { return config.getInt("Scoreboards.Inspect.Display_Time", 10); }
public boolean getInspectUseChat() { return config.getBoolean("Scoreboard.Types.Inspect.Print", true); }
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 int getSkillScoreboardTime() { return config.getInt("Scoreboards.Skillname.Display_Time", 10); }
public boolean getCooldownUseChat() { return config.getBoolean("Scoreboard.Types.Cooldown.Print", false); }
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 */
public int getPurgeInterval() { return config.getInt("Database_Purging.Purge_Interval", -1); }
@@ -235,24 +269,17 @@ public class Config extends AutoUpdateConfigLoader {
/* mySQL */
public boolean getUseMySQL() { return config.getBoolean("MySQL.Enabled", false); }
public String getMySQLTablePrefix() { return config.getString("MySQL.Database.TablePrefix", "mcmmo_"); }
public String getMySQLDatabaseName() { return getStringIncludingInts(config, "MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts(config, "MySQL.Database.User_Name"); }
public String getMySQLDatabaseName() { return getStringIncludingInts("MySQL.Database.Name"); }
public String getMySQLUserName() { return getStringIncludingInts("MySQL.Database.User_Name"); }
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
public String getMySQLUserPassword() {
if (getStringIncludingInts(config, "MySQL.Database.User_Password") != null) {
return getStringIncludingInts(config, "MySQL.Database.User_Password");
}
return "";
}
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
String str = cfg.getString(key);
private String getStringIncludingInts(String key) {
String str = config.getString(key);
if (str == null) {
str = String.valueOf(cfg.getInt(key));
str = String.valueOf(config.getInt(key));
}
if (str.equals("0")) {
@@ -265,25 +292,25 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getHardcoreStatLossEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreStatLossEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Death_Stat_Loss.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0); }
public 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 boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); }
public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
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 getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* Items */
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 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 getChimaeraPreventUseUnderground() { return config.getBoolean("Items.Chimaera_Wing.Prevent_Use_Underground", true); }
public int getChimaeraCooldown() { return config.getInt("Items.Chimaera_Wing.Cooldown", 240); }
@@ -304,11 +331,11 @@ public class Config extends AutoUpdateConfigLoader {
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
public boolean getExpShareEnabled() { return config.getBoolean("Party.Sharing.ExpShare_enabled", true); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1); }
public double getPartyShareBonusIncrease() { return config.getDouble("Party.Sharing.ExpShare_bonus_increase", 0.05); }
public double getPartyShareBonusCap() { return config.getDouble("Party.Sharing.ExpShare_bonus_cap", 1.5); }
public double getPartyShareBonusBase() { return config.getDouble("Party.Sharing.ExpShare_bonus_base", 1.1D); }
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.5D); }
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 */
public int getPTPCommandCooldown() { return config.getInt("Commands.ptp.Cooldown", 120); }
@@ -319,7 +346,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getPTPCommandWorldPermissions() { return config.getBoolean("Commands.ptp.World_Based_Permissions", false); }
/* Inspect command distance */
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30); }
public double getInspectDistance() { return config.getDouble("Commands.inspect.Max_Distance", 30.0D); }
/*
* ABILITY SETTINGS
@@ -331,10 +358,10 @@ public class Config extends AutoUpdateConfigLoader {
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 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 */
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 1); }
/* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
@@ -368,12 +395,12 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* 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 */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
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_ID", "GOLD_BLOCK")); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
public boolean getRepairConfirmRequired() { return config.getBoolean("Skills.Repair.Confirm_Required", true); }
@@ -385,7 +412,7 @@ public class Config extends AutoUpdateConfigLoader {
public int getTamingCOTWHorseCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Apples_Required", 10); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40); }
public 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 */
@@ -395,8 +422,9 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
/* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
public boolean getAcrobaticsPreventAFK() { return config.getBoolean("Skills.Acrobatics.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 */
public int getPowerLevelCap() {

View File

@@ -1,11 +1,6 @@
package com.gmail.nossr50.config;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;
import org.bukkit.configuration.file.FileConfiguration;
@@ -16,7 +11,7 @@ import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
protected String fileName;
protected File configFile;
private File configFile;
protected FileConfiguration config;
public ConfigLoader(String relativePath, String fileName) {
@@ -34,7 +29,13 @@ public abstract class ConfigLoader {
protected void loadFile() {
if (!configFile.exists()) {
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 {
plugin.debug("Loading mcMMO " + fileName + " File...");
@@ -45,53 +46,6 @@ public abstract class ConfigLoader {
protected abstract void loadKeys();
protected void createFile() {
configFile.getParentFile().mkdirs();
InputStream inputStream = plugin.getResource(fileName);
if (inputStream == null) {
plugin.getLogger().severe("Missing resource file: '" + fileName + "' please notify the plugin authors");
return;
}
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream(configFile);
int read;
byte[] bytes = new byte[1024];
while ((read = inputStream.read(bytes)) != -1) {
outputStream.write(bytes, 0, read);
}
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
catch (IOException e) {
e.printStackTrace();
}
finally {
if (outputStream != null) {
try {
outputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
try {
inputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
protected boolean validateKeys() {
return true;
}
@@ -114,4 +68,23 @@ public abstract class ConfigLoader {
plugin.noErrorsInConfigFiles = false;
}
}
public File getFile() {
return configFile;
}
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

@@ -9,7 +9,7 @@ import org.bukkit.entity.EntityType;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.skills.repair.RepairMaterialType;
import com.gmail.nossr50.skills.repair.repairables.RepairMaterialType;
import com.gmail.nossr50.util.StringUtils;
public class ExperienceConfig extends AutoUpdateConfigLoader {
@@ -85,11 +85,27 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
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!");
@@ -176,8 +192,16 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* 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); }

View File

@@ -1,33 +1,34 @@
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.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
import com.gmail.nossr50.skills.repair.Repair;
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 CustomArmorConfig extends ConfigLoader {
private static CustomArmorConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables;
public List<Integer> customBootIDs = new ArrayList<Integer>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
private List<Material> customBoots = new ArrayList<Material>();
private List<Material> customChestplates = new ArrayList<Material>();
private List<Material> customHelmets = new ArrayList<Material>();
private List<Material> customLeggings = new ArrayList<Material>();
public CustomArmorConfig() {
super("ModConfigs", "armor.yml");
super("mods", "armor.yml");
loadKeys();
}
@@ -51,13 +52,22 @@ public class CustomArmorConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBootIDs);
loadArmor("Chestplates", customChestplateIDs);
loadArmor("Helmets", customHelmetIDs);
loadArmor("Leggings", customLeggingIDs);
loadArmor("Boots", customBoots);
loadArmor("Chestplates", customChestplates);
loadArmor("Helmets", customHelmets);
loadArmor("Leggings", customLeggings);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadArmor(String armorType, List<Integer> idList) {
private void loadArmor(String armorType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
if (armorSection == null) {
@@ -67,35 +77,60 @@ public class CustomArmorConfig extends ConfigLoader {
Set<String> armorConfigSet = armorSection.getKeys(false);
for (String armorName : armorConfigSet) {
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
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 (config.contains(armorType + "." + armorName + "." + ".ID")) {
needsUpdate = true;
return;
}
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
Material armorMaterial = Material.matchMaterial(armorName);
if (armorMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + armorName);
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
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;
}
CustomItem armor;
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);
}
short durability = armorMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 70);
}
repairables.add(RepairableFactory.getRepairable(armorMaterial, repairMaterial, repairData, repairQuantity, 0, durability, RepairItemType.ARMOR, RepairMaterialType.OTHER, 1.0));
}
armor = new CustomItem(id, durability);
idList.add(id);
customIDs.add(id);
customArmorList.add(armor);
customArmor.put(id, armor);
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;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader;
@@ -14,20 +15,21 @@ import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlockConfig extends ConfigLoader {
private static CustomBlockConfig instance;
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customAbilityBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
private boolean needsUpdate = false;
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() {
super("ModConfigs", "blocks.yml");
super("mods", "blocks.yml");
loadKeys();
}
@@ -46,9 +48,18 @@ public class CustomBlockConfig extends ConfigLoader {
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
loadBlocks("Ability_Blocks", customAbilityBlocks);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadBlocks(String skillType, List<ItemStack> blockList) {
private void loadBlocks(String skillType, List<MaterialData> blockList) {
if (needsUpdate) {
return;
}
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
if (skillSection == null) {
@@ -58,63 +69,80 @@ public class CustomBlockConfig extends ConfigLoader {
Set<String> skillConfigSet = skillSection.getKeys(false);
for (String blockName : skillConfigSet) {
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
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);
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
needsUpdate = true;
return;
}
CustomBlock block;
ItemStack itemDrop;
ItemStack blockItem;
String[] blockInfo = blockName.split("[|]");
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
Material blockMaterial = Material.matchMaterial(blockInfo[0]);
if (blockMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + blockInfo[0]);
continue;
}
byte blockData = Byte.valueOf(blockInfo[1]);
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
blockList.add(blockMaterialData);
if (skillType.equals("Ability_Blocks")) {
blockItem = (new MaterialData(id, data)).toItemStack(1);
blockList.add(blockItem);
continue;
}
if (dropItem && dropID == 0) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
dropItem = false;
}
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);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain");
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem);
customOres.add(blockMaterialData);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockItem);
customLogs.add(blockMaterialData);
}
else {
customLeaves.add(blockItem);
block.setXpGain(0); // Leaves don't grant XP
customLeaves.add(blockMaterialData);
xp = 0; // Leaves don't grant XP
}
}
blockList.add(blockItem);
customItems.add(blockItem);
customBlocks.add(block);
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled")));
}
}
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.HashMap;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import org.apache.commons.lang.ClassUtils;
public class CustomEntityConfig extends ConfigLoader {
private static CustomEntityConfig instance;
public List<Integer> customEntityIds = new ArrayList<Integer>();
public List<Integer> customHostileEntityIds = new ArrayList<Integer>();
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>();
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
private HashMap<String, CustomEntity> customEntityTypeMap = new HashMap<String, CustomEntity>();
public CustomEntityConfig() {
super("ModConfigs", "entities.yml");
super("mods", "entities.yml");
loadKeys();
}
@@ -37,48 +32,86 @@ public class CustomEntityConfig extends ConfigLoader {
@Override
protected void loadKeys() {
loadMobs("Hostile", customHostileEntityIds);
loadMobs("Neutral", customNeutralEntityIds);
loadMobs("Passive", customPassiveEntityIds);
}
private void loadMobs(String entityType, List<Integer> entityIdList) {
ConfigurationSection entitySection = config.getConfigurationSection(entityType);
if (entitySection == null) {
if (config.getConfigurationSection("Hostile") != null) {
backup();
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) {
int id = config.getInt(entityType + "." + entityName + ".ID", 0);
EntityType type = EntityType.fromId(id);
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0);
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;
try {
clazz = ClassUtils.getClass(className);
}
catch (ClassNotFoundException e) {
plugin.getLogger().warning("Invalid class (" + className + ") detected for " + entityName + ".");
plugin.getLogger().warning("This custom entity may not function properly.");
}
if (canBeSummoned && (callOfTheWildId == 0 || callOfTheWildAmount == 0)) {
plugin.getLogger().warning("Incomplete Call of the Wild information. This enitity will not be able to be summoned by Call of the Wild.");
String entityTypeName = entityName.replace("_", ".");
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;
}
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);
customEntityTypes.add(type);
customEntities.add(entity);
customEntityTypeMap.put(entityTypeName, entity);
customEntityClassMap.put(clazz == null ? null : clazz.getName(), 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,30 +5,36 @@ import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
import com.gmail.nossr50.skills.repair.Repair;
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 {
private static CustomToolConfig instance;
private boolean needsUpdate = false;
private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
private List<Material> customAxes = new ArrayList<Material>();
private List<Material> customBows = new ArrayList<Material>();
private List<Material> customHoes = new ArrayList<Material>();
private List<Material> customPickaxes = new ArrayList<Material>();
private List<Material> customShovels = new ArrayList<Material>();
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() {
super("ModConfigs", "tools.yml");
super("mods", "tools.yml");
loadKeys();
}
@@ -52,15 +58,24 @@ public class CustomToolConfig extends ConfigLoader {
protected void loadKeys() {
repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxeIDs);
loadTool("Bows", customBowIDs);
loadTool("Hoes", customHoeIDs);
loadTool("Pickaxes", customPickaxeIDs);
loadTool("Shovels", customShovelIDs);
loadTool("Swords", customSwordIDs);
loadTool("Axes", customAxes);
loadTool("Bows", customBows);
loadTool("Hoes", customHoes);
loadTool("Pickaxes", customPickaxes);
loadTool("Shovels", customShovels);
loadTool("Swords", customSwords);
if (needsUpdate) {
needsUpdate = false;
backup();
}
}
private void loadTool(String toolType, List<Integer> idList) {
private void loadTool(String toolType, List<Material> materialList) {
if (needsUpdate) {
return;
}
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
if (toolSection == null) {
@@ -70,38 +85,83 @@ public class CustomToolConfig extends ConfigLoader {
Set<String> toolConfigSet = toolSection.getKeys(false);
for (String toolName : toolConfigSet) {
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
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 (config.contains(toolType + "." + toolName + "." + ".ID")) {
needsUpdate = true;
return;
}
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
Material toolMaterial = Material.matchMaterial(toolName);
if (toolMaterial == null) {
plugin.getLogger().warning("Invalid material name. This item will be skipped. - " + toolName);
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
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;
}
CustomTool tool;
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);
}
short durability = toolMaterial.getMaxDurability();
if (durability == 0) {
durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 60);
}
repairables.add(RepairableFactory.getRepairable(toolMaterial, repairMaterial, repairData, 0, repairQuantity, durability, RepairItemType.TOOL, RepairMaterialType.OTHER, 1.0));
}
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
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);
idList.add(id);
customIDs.add(id);
customToolList.add(tool);
customTools.put(id, tool);
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 com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import org.getspout.spoutapi.keyboard.Keyboard;
public class SpoutConfig extends ConfigLoader {
private static SpoutConfig instance;
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,23 +3,26 @@ package com.gmail.nossr50.config.treasure;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
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.PotionType;
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.FishingTreasure;
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.Treasure;
import com.gmail.nossr50.util.EnchantmentUtils;
public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
@@ -45,6 +48,7 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromEnderman = 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> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
@@ -58,7 +62,8 @@ public class TreasureConfig extends ConfigLoader {
public List<ShakeTreasure> shakeFromWitch = 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() {
super("treasures.yml");
@@ -75,375 +80,310 @@ public class TreasureConfig extends ConfigLoader {
@Override
protected void loadKeys() {
Map<String, Treasure> treasures = new HashMap<String, Treasure>();
ConfigurationSection treasureSection = config.getConfigurationSection("Treasures");
if (config.getConfigurationSection("Treasures") != null) {
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) {
return;
}
for (String treasureName : treasureSection.getKeys(false)) {
// Initialize fishing HashMap
for (Rarity rarity : Rarity.values()) {
if (!fishingRewards.containsKey(rarity)) {
fishingRewards.put(rarity, (new ArrayList<FishingTreasure>()));
}
}
for (String treasureName : treasureSection.getKeys(false)) {
// Validate all the things!
List<String> reason = new ArrayList<String>();
/*
* ID, Amount, and Data
* Material, Amount, and Data
*/
Material material;
if (!config.contains("Treasures." + treasureName + ".ID")) {
reason.add("Missing ID");
if (treasureName.contains("POTION")) {
material = Material.POTION;
}
else if (treasureName.contains("INK_SACK")) {
material = Material.INK_SACK;
}
else {
material = Material.matchMaterial(treasureName);
}
if (!config.contains("Treasures." + treasureName + ".Amount")) {
reason.add("Missing Amount");
int amount = config.getInt(type + "." + treasureName + ".Amount");
int data = config.getInt(type + "." + treasureName + ".Data");
if (material == null) {
reason.add("Invalid material: " + treasureName);
}
if (!config.contains("Treasures." + treasureName + ".Data")) {
reason.add("Missing Data");
if (amount <= 0) {
reason.add("Amount of " + treasureName + " must be greater than 0! " + amount);
}
int id = config.getInt("Treasures." + treasureName + ".ID");
int amount = config.getInt("Treasures." + treasureName + ".Amount");
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);
if (material != null && material.isBlock() && (data > 127 || data < -128)) {
reason.add("Data of " + treasureName + " is invalid! " + data);
}
/*
* XP, Drop Chance, and Drop Level
*/
if (!config.contains("Treasures." + treasureName + ".XP")) {
reason.add("Missing XP");
}
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");
int xp = config.getInt(type + "." + treasureName + ".XP");
double dropChance = config.getDouble(type + "." + treasureName + ".Drop_Chance");
int dropLevel = config.getInt(type + "." + treasureName + ".Drop_Level");
if (xp < 0) {
reason.add("Invalid xp: " + xp);
reason.add(treasureName + " has an invalid XP value: " + xp);
}
if (dropChance < 0) {
reason.add("Invalid Drop_Chance: " + dropChance);
if (dropChance < 0.0D) {
reason.add(treasureName + " has an invalid Drop_Chance: " + dropChance);
}
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;
if (config.contains("Treasures." + treasureName + ".Potion_Type")) {
String potionType = config.getString("Treasures." + treasureName + ".Potion_Type");
if (treasureName.contains("POTION")) {
String potionType = treasureName.substring(7);
try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase())).toItemStack(amount);
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType);
}
}
else {
item = (new MaterialData(id, (byte) data)).toItemStack(amount);
}
/*
* 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 (noErrorsInConfig(reason)) {
FishingTreasure fTreasure = new FishingTreasure(item, xp, dropChance, dropLevel, maxLevel);
treasures.put(treasureName, fTreasure);
}
}
else if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
if (config.getConfigurationSection("Treasures." + treasureName + ".Drops_From").getKeys(false).size() != 1) {
reason.add("This can only be a shake drop.");
}
if (!config.contains("Treasures." + treasureName + ".Mob")) {
reason.add("Missing Mob");
}
String mobType = config.getString("Treasures." + treasureName + ".Mob");
EntityType mob = null;
else if (treasureName.contains("INK_SACK")) {
String color = treasureName.substring(9);
try {
mob = EntityType.valueOf(mobType.toUpperCase().trim());
}
catch (IllegalArgumentException ex){
reason.add("Invalid Mob: " + mobType);
}
Dye dye = new Dye();
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
if (noErrorsInConfig(reason)) {
ShakeTreasure sTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel, mob);
treasures.put(treasureName, sTreasure);
item = dye.toItemStack(amount);
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Dye_Color: " + color);
}
}
else {
ExcavationTreasure eTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
HylianTreasure hTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
else if (material != null) {
item = new ItemStack(material, amount, (short) data);
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Dirt", false)) {
eTreasure.setDropsFromDirt();
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(config.getString(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Grass", false)) {
eTreasure.setDropsFromGrass();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Sand", false)) {
eTreasure.setDropsFromSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Gravel", false)) {
eTreasure.setDropsFromGravel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Clay", false)) {
eTreasure.setDropsFromClay();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Mycelium", false)) {
eTreasure.setDropsFromMycel();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Soul_Sand", false)) {
eTreasure.setDropsFromSoulSand();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Snow", false)) {
eTreasure.setDropsFromSnow();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Bushes", false)) {
hTreasure.setDropsFromBushes();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Flowers", false)) {
hTreasure.setDropsFromFlowers();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Pots", false)) {
hTreasure.setDropsFromPots();
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Fishing", false)) {
reason.add("This cannot also be a fishing drop.");
}
if (config.getBoolean("Treasures." + treasureName + ".Drops_From.Shake", false)) {
reason.add("This cannot also be a shake drop.");
}
if (noErrorsInConfig(reason) && hTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, eTreasure);
}
else if (noErrorsInConfig(reason) && eTreasure.getDropsFrom() == (byte) 0x0) {
treasures.put(treasureName, hTreasure);
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setLore(config.getStringList(type + "." + treasureName + "Custom_Name"));
item.setItemMeta(itemMeta);
}
}
}
List<String> excavationTreasures = config.getStringList("Excavation.Treasure");
List<String> fishingTreasures = config.getStringList("Fishing.Treasure");
List<String> hylianTreasures = config.getStringList("Hylian_Luck.Treasure");
List<String> shakeTreasures = config.getStringList("Shake.Treasure");
for (Entry<String, Treasure> nextEntry : treasures.entrySet()) {
String treasureKey = nextEntry.getKey();
Treasure treasure = nextEntry.getValue();
if (treasure instanceof FishingTreasure) {
if (fishingTreasures == null || !fishingTreasures.contains(treasureKey)) {
continue;
if (noErrorsInConfig(reason)) {
if (isFishing) {
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
}
else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
fishingRewards.add((FishingTreasure) treasure);
}
else if (treasure instanceof ShakeTreasure) {
if (shakeTreasures == null || !shakeTreasures.contains(treasureKey)) {
continue;
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");
ShakeTreasure e = (ShakeTreasure) treasure;
switch (e.getMob()) {
case BLAZE:
shakeFromBlaze.add(e);
break;
if (dropList.contains("Dirt")) {
excavationFromDirt.add(excavationTreasure);
}
case CAVE_SPIDER:
shakeFromCaveSpider.add(e);
break;
if (dropList.contains("Grass")) {
excavationFromGrass.add(excavationTreasure);
}
case CHICKEN:
shakeFromChicken.add(e);
break;
if (dropList.contains("Sand")) {
excavationFromSand.add(excavationTreasure);
}
case COW:
shakeFromCow.add(e);
break;
if (dropList.contains("Gravel")) {
excavationFromGravel.add(excavationTreasure);
}
case CREEPER:
shakeFromCreeper.add(e);
break;
if (dropList.contains("Clay")) {
excavationFromClay.add(excavationTreasure);
}
case ENDERMAN:
shakeFromEnderman.add(e);
break;
if (dropList.contains("Mycelium")) {
excavationFromMycel.add(excavationTreasure);
}
case GHAST:
shakeFromGhast.add(e);
break;
if (dropList.contains("Soul_Sand")) {
excavationFromSoulSand.add(excavationTreasure);
}
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;
if (dropList.contains("Snow")) {
excavationFromSnow.add(excavationTreasure);
}
}
else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
HylianTreasure hTreasure = (HylianTreasure) treasure;
if (dropList.contains("Bushes")) {
hylianFromBushes.add(hylianTreasure);
}
if (hTreasure.getDropsFromBushes()) {
hylianFromBushes.add(hTreasure);
}
if (dropList.contains("Flowers")) {
hylianFromFlowers.add(hylianTreasure);
}
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);
}
if (eTreasure.getDropsFromSnow()) {
excavationFromSnow.add(eTreasure);
if (dropList.contains("Pots")) {
hylianFromPots.add(hylianTreasure);
}
}
}
}
}
private void loadEnchantments() {
for (Rarity rarity : Rarity.values()) {
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
continue;
}
if (!fishingEnchantments.containsKey(rarity)) {
fishingEnchantments.put(rarity, (new ArrayList<EnchantmentTreasure>()));
}
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;
}
fishingEnchantments.get(rarity).add(new EnchantmentTreasure(enchantment, level));
}
}
}
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
}

View File

@@ -7,10 +7,13 @@ 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.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
public interface DatabaseManager {
// One month in milliseconds
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.
@@ -34,8 +37,9 @@ public interface DatabaseManager {
* Save a user to the database.
*
* @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.
@@ -45,15 +49,18 @@ public interface DatabaseManager {
* @param statsPerPage The number of stats per page
* @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
* @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.

View File

@@ -10,7 +10,7 @@ public class DatabaseManagerFactory {
public static DatabaseManager getDatabaseManager() {
if (customManager != null) {
try {
return createCustomDatabaseManager(customManager);
return createDefaultCustomDatabaseManager();
}
catch (Exception e) {
mcMMO.p.debug("Could not create custom database manager");
@@ -29,17 +29,18 @@ public class DatabaseManagerFactory {
/**
* Sets the custom DatabaseManager class for mcMMO to use. This should be
* called prior to mcMMO enabling.
* <p>
* <p/>
* The provided class must have an empty constructor, which is the one
* that will be used.
* <p>
* <p/>
* This method is intended for API use, but it should not be considered
* stable. This method is subject to change and/or removal in future
* versions.
*
* @param clazz the DatabaseManager class to use
*
* @throws IllegalArgumentException if the provided class does not have
* an empty constructor
* an empty constructor
*/
public static void setCustomDatabaseManagerClass(Class<? extends DatabaseManager> clazz) {
try {
@@ -63,13 +64,24 @@ public class DatabaseManagerFactory {
case SQL:
return new SQLDatabaseManager();
case CUSTOM:
try {
return createDefaultCustomDatabaseManager();
}
catch (Throwable e) {
e.printStackTrace();
}
default:
return null;
}
}
//TODO: Why is clazz never used here?
public static DatabaseManager createDefaultCustomDatabaseManager() throws Throwable {
return customManager.getConstructor((Class<?>) null).newInstance((Object[]) null);
}
public static DatabaseManager createCustomDatabaseManager(Class<? extends DatabaseManager> clazz) throws Throwable {
return customManager.getConstructor((Class<?>) clazz).newInstance((Object[]) null);
return clazz.getConstructor((Class<?>) null).newInstance((Object[]) null);
}
}

View File

@@ -15,7 +15,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import com.gmail.nossr50.mcMMO;
@@ -26,7 +25,6 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.Misc;
public final class FlatfileDatabaseManager implements DatabaseManager {
@@ -123,9 +121,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
try {
lastPlayed = Long.parseLong(character[37]) * Misc.TIME_CONVERSION_FACTOR;
}
catch (NumberFormatException e) {}
catch (NumberFormatException e) {
}
if (lastPlayed == 0) {
OfflinePlayer player = Bukkit.getOfflinePlayer(name);
OfflinePlayer player = mcMMO.p.getServer().getOfflinePlayer(name);
lastPlayed = player.getLastPlayed();
rewrite = true;
}
@@ -204,7 +203,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
return worked;
}
public void saveUser(PlayerProfile profile) {
public boolean saveUser(PlayerProfile profile) {
String playerName = profile.getPlayerName();
BufferedReader in = null;
@@ -259,8 +258,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
writer.append((int) profile.getSkillDATS(AbilityType.SERRATED_STRIKES)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SKULL_SPLITTER)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.SUPER_BREAKER)).append(":");
HudType hudType = profile.getHudType();
writer.append(hudType == null ? "STANDARD" : hudType.toString()).append(":");
writer.append(":");
writer.append(profile.getSkillLevel(SkillType.FISHING)).append(":");
writer.append(profile.getSkillXpLevel(SkillType.FISHING)).append(":");
writer.append((int) profile.getSkillDATS(AbilityType.BLAST_MINING)).append(":");
@@ -274,9 +272,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Write the new file
out = new FileWriter(usersFilePath);
out.write(writer.toString());
return true;
}
catch (Exception e) {
e.printStackTrace();
return false;
}
finally {
tryClose(in);
@@ -285,24 +285,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();
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;
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();
Map<String, Integer> skills = new HashMap<String, Integer>();
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
for (SkillType skill : SkillType.nonChildSkills()) {
skills.put(skill.name(), getPlayerRank(playerName, playerStatHash.get(skill)));
for (SkillType skill : SkillType.NON_CHILD_SKILLS) {
skills.put(skill, getPlayerRank(playerName, playerStatHash.get(skill)));
}
skills.put("ALL", getPlayerRank(playerName, powerLevels));
skills.put(null, getPlayerRank(playerName, powerLevels));
return skills;
}
@@ -348,7 +348,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
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:"); // FishingXp
out.append("0:"); // Blast Mining
@@ -387,28 +387,41 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
PlayerProfile p = loadFromLine(character);
in.close();
return p;
}
// Didn't find the player, create a new one
if (create) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
}
catch (Exception e) {
e.printStackTrace();
}
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) {
newUser(playerName);
return new PlayerProfile(playerName, true);
}
// Return unloaded profile
return new PlayerProfile(playerName);
}
public void convertUsers(DatabaseManager destination) {
BufferedReader in = null;
String usersFilePath = mcMMO.getUsersFilePath();
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
synchronized (fileWritingLock) {
try {
@@ -425,6 +438,8 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
catch (Exception e) {
e.printStackTrace();
}
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
}
}
catch (Exception e) {
@@ -436,11 +451,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
public boolean checkConnected() {
// Not implemented
return true;
}
public List<String> getStoredUsers() {
ArrayList<String> users = new ArrayList<String>();
BufferedReader in = null;
@@ -495,6 +505,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
List<PlayerStat> fishing = new ArrayList<PlayerStat>();
BufferedReader in = null;
String playerName = null;
// Read from the FlatFile database and fill our arrays with information
synchronized (fileWritingLock) {
try {
@@ -503,7 +514,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
while ((line = in.readLine()) != null) {
String[] data = line.split(":");
String playerName = data[0];
playerName = data[0];
int powerLevel = 0;
Map<SkillType, Integer> skills = getSkillMapFromLine(data);
@@ -525,7 +536,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
}
}
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 {
tryClose(in);
@@ -579,6 +590,11 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
HashSet<String> players = new HashSet<String>();
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 + ":";
@@ -590,70 +606,81 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
continue;
}
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;
}
else if (character.length < 33) {
// Before Version 1.0 - Drop
mcMMO.p.getLogger().warning("Dropping malformed or before version 1.0 line from database - " + line);
}
else {
String oldVersion = null;
StringBuilder newLine = new StringBuilder(line);
boolean announce = false;
if (character.length <= 33) {
// Introduction of HUDType
// Version 1.1.06
// commit 78f79213cdd7190cd11ae54526f3b4ea42078e8a
newLine.append("STANDARD").append(":");
oldVersion = "1.1.06";
}
if (character.length <= 35) {
// Introduction of Fishing
// Version 1.2.00
// commit a814b57311bc7734661109f0e77fc8bab3a0bd29
newLine.append(0).append(":");
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.2.00";
}
}
if (character.length <= 36) {
// Introduction of Blast Mining cooldowns
// Version 1.3.00-dev
// commit fadbaf429d6b4764b8f1ad0efaa524a090e82ef5
newLine.append(0).append(":");
if (oldVersion == null) {
oldVersion = "1.3.00";
}
}
if (character.length <= 37) {
// Making old-purge work with flatfile
// Version 1.4.00-dev
// commmit 3f6c07ba6aaf44e388cc3b882cac3d8f51d0ac28
// XXX Cannot create an OfflinePlayer at startup, use 0 and fix in purge
newLine.append("0").append(":");
announce = true; // TODO move this down
if (oldVersion == null) {
oldVersion = "1.4.00";
}
}
if (character.length <= 38) {
// Addition of mob healthbars
// Version 1.4.06
// commit da29185b7dc7e0d992754bba555576d48fa08aa6
newLine.append(Config.getInstance().getMobHealthbarDefault().toString()).append(":");
if (oldVersion == null) {
oldVersion = "1.4.06";
}
}
if (announce) {
mcMMO.p.debug("Updating database line for player " + character[0] + " from before version " + oldVersion);
}
writer.append(newLine).append("\r\n");
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
@@ -728,7 +755,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = getSkillMapFromLine(character); // Skill levels
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType;
// TODO on updates, put new values in a try{} ?
@@ -759,13 +785,6 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Acrobatics - Unused
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
try {
hudType = HudType.valueOf(character[33]);
}
catch (Exception e) {
hudType = HudType.STANDARD; // Shouldn't happen unless database is being tampered with
}
try {
mobHealthbarType = MobHealthbarType.valueOf(character[38]);
}
@@ -773,7 +792,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
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) {

View File

@@ -12,7 +12,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Level;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -23,7 +22,7 @@ import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.runnables.database.SQLDatabaseKeepaliveTask;
import com.gmail.nossr50.runnables.database.SQLReconnectTask;
import com.gmail.nossr50.util.Misc;
@@ -52,6 +51,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
protected SQLDatabaseManager() {
checkStructure();
new SQLDatabaseKeepaliveTask(this).runTaskTimerAsynchronously(mcMMO.p, 10, 60L * 60 * Misc.TICK_CONVERSION_FACTOR);
}
public void purgePowerlessUsers() {
@@ -93,7 +94,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
"WHERE ((" + currentTime + " - lastlogin * " + Misc.TIME_CONVERSION_FACTOR + ") > " + PURGE_TIME + ")");
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) {
@@ -114,9 +115,9 @@ public final class SQLDatabaseManager implements DatabaseManager {
return success;
}
public void saveUser(PlayerProfile profile) {
public boolean saveUser(PlayerProfile profile) {
if (!checkConnected()) {
return;
return false;
}
int userId = readId(profile.getPlayerName());
@@ -124,16 +125,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
newUser(profile.getPlayerName());
userId = readId(profile.getPlayerName());
if (userId == -1) {
mcMMO.p.getLogger().log(Level.WARNING, "Failed to save user " + profile.getPlayerName());
return;
return false;
}
}
boolean success = true;
MobHealthbarType mobHealthbarType = profile.getMobHealthbarType();
HudType hudType = profile.getHudType();
saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
saveHuds(userId, (hudType == null ? "STANDARD" : hudType.toString()), (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
saveLongs(
success &= saveLogin(userId, ((int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
success &= saveHuds(userId, (mobHealthbarType == null ? Config.getInstance().getMobHealthbarDefault().toString() : mobHealthbarType.toString()));
success &= saveLongs(
"UPDATE " + tablePrefix + "cooldowns SET "
+ " mining = ?, woodcutting = ?, unarmed = ?"
+ ", herbalism = ?, excavation = ?, swords = ?"
@@ -147,7 +147,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillDATS(AbilityType.SERRATED_STRIKES),
profile.getSkillDATS(AbilityType.SKULL_SPLITTER),
profile.getSkillDATS(AbilityType.BLAST_MINING));
saveIntegers(
success &= saveIntegers(
"UPDATE " + tablePrefix + "skills SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -166,7 +166,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillLevel(SkillType.ACROBATICS),
profile.getSkillLevel(SkillType.FISHING),
userId);
saveIntegers(
success &= saveIntegers(
"UPDATE " + tablePrefix + "experience SET "
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
@@ -185,13 +185,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
profile.getSkillXpLevel(SkillType.ACROBATICS),
profile.getSkillXpLevel(SkillType.FISHING),
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>();
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;
PreparedStatement statement = null;
@@ -229,14 +230,14 @@ public final class SQLDatabaseManager implements DatabaseManager {
return stats;
}
public Map<String, Integer> readRank(String playerName) {
Map<String, Integer> skills = new HashMap<String, Integer>();
public Map<SkillType, Integer> readRank(String playerName) {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>();
if (checkConnected()) {
ResultSet resultSet;
try {
for (SkillType skillType : SkillType.nonChildSkills()) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
String skillName = skillType.name().toLowerCase();
String sql = "SELECT COUNT(*) AS rank FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id WHERE " + skillName + " > 0 " +
"AND " + skillName + " > (SELECT " + skillName + " FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON user_id = id " +
@@ -261,7 +262,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
while (resultSet.next()) {
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
skills.put(skillType.name(), rank + resultSet.getRow());
skills.put(skillType, rank + resultSet.getRow());
break;
}
}
@@ -298,7 +299,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
while (resultSet.next()) {
if (resultSet.getString("user").equalsIgnoreCase(playerName)) {
skills.put("ALL", rank + resultSet.getRow());
skills.put(null, rank + resultSet.getRow());
break;
}
}
@@ -345,6 +346,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
public PlayerProfile loadPlayerProfile(String playerName, boolean create) {
return loadPlayerProfile(playerName, create, true);
}
private PlayerProfile loadPlayerProfile(String playerName, boolean create, boolean retry) {
if (!checkConnected()) {
return new PlayerProfile(playerName, false); // return fake profile if not connected
}
@@ -357,7 +362,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, "
+ "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, "
+ "h.hudtype, h.mobhealthbar "
+ "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -374,7 +379,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
result.close();
return ret;
}
catch (SQLException e) {}
catch (SQLException e) {
}
}
result.close();
}
@@ -394,6 +400,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
// 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
int id = readId(playerName);
@@ -402,14 +413,16 @@ public final class SQLDatabaseManager implements DatabaseManager {
// There is no such user
if (create) {
newUser(playerName);
return loadPlayerProfile(playerName, false, false);
}
return new PlayerProfile(playerName, create);
// Return unloaded profile if can't create
return new PlayerProfile(playerName, false);
}
// There is such a user
writeMissingRows(id);
// Retry, and abort on re-failure
return loadPlayerProfile(playerName, false);
return loadPlayerProfile(playerName, create, false);
}
public void convertUsers(DatabaseManager destination) {
@@ -425,7 +438,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, "
+ "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, "
+ "h.hudtype, h.mobhealthbar "
+ "h.mobhealthbar "
+ "FROM " + tablePrefix + "users u "
+ "JOIN " + tablePrefix + "skills s ON (u.id = s.user_id) "
+ "JOIN " + tablePrefix + "experience e ON (u.id = e.user_id) "
@@ -434,6 +447,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "WHERE u.user = ?");
List<String> usernames = getStoredUsers();
ResultSet result = null;
int convertedUsers = 0;
long startMillis = System.currentTimeMillis();
for (String playerName : usernames) {
statement.setString(1, playerName);
try {
@@ -445,6 +460,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
catch (SQLException e) {
// Ignore
}
convertedUsers++;
Misc.printProgress(convertedUsers, progressInterval, startMillis);
}
}
catch (SQLException e) {
@@ -454,13 +471,15 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (statement != null) {
try {
statement.close();
} catch (SQLException e) {
}
catch (SQLException e) {
// Ignore
}
}
}
}
/**
* Check connection status and re-establish if dead or stale.
*
@@ -571,7 +590,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
}
catch (SQLException e) {
// Ignore
}
}
@@ -634,7 +654,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "UNIQUE KEY `user` (`user`)) DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "huds` ("
+ "`user_id` int(10) unsigned NOT NULL,"
+ "`hudtype` varchar(50) NOT NULL DEFAULT 'STANDARD',"
+ "`mobhealthbar` varchar(50) NOT NULL DEFAULT '" + Config.getInstance().getMobHealthbarDefault() + "',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
@@ -735,6 +754,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
write("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;");
return;
case DROPPED_SPOUT:
write("ALTER TABLE `" + tablePrefix + "huds` DROP COLUMN `hudtype` ;");
return;
case KILL_ORPHANS:
mcMMO.p.getLogger().info("Killing orphans");
write(
@@ -841,7 +864,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return true;
}
catch (SQLException ex) {
if (!sql.equalsIgnoreCase("ALTER TABLE `" + tablePrefix + "users` DROP COLUMN `party` ;")) {
if (!sql.contains("DROP COLUMN")) {
printErrors(ex);
}
return false;
@@ -1019,7 +1042,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private void saveIntegers(String sql, int... args) {
private boolean saveIntegers(String sql, int... args) {
PreparedStatement statement = null;
try {
@@ -1031,9 +1054,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1047,7 +1072,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;
try {
@@ -1060,9 +1085,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(i++, id);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1097,7 +1124,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return id;
}
private void saveLogin(int id, long login) {
private boolean saveLogin(int id, long login) {
PreparedStatement statement = null;
try {
@@ -1105,9 +1132,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setLong(1, login);
statement.setInt(2, id);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1121,18 +1150,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;
try {
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET hudtype = ?, mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, hudType);
statement.setString(2, mobHealthBar);
statement.setInt(3, userId);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ? WHERE user_id = ?");
statement.setString(1, mobHealthBar);
statement.setInt(2, userId);
statement.execute();
return true;
}
catch (SQLException ex) {
printErrors(ex);
return false;
}
finally {
if (statement != null) {
@@ -1150,7 +1180,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
Map<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); // Skill & Level
Map<SkillType, Float> skillsXp = new HashMap<SkillType, Float>(); // Skill & XP
Map<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); // Ability & Cooldown
HudType hudType;
MobHealthbarType mobHealthbarType;
final int OFFSET_SKILLS = 0; // TODO update these numbers when the query changes (a new skill is added)
@@ -1197,13 +1226,6 @@ public final class SQLDatabaseManager implements DatabaseManager {
// Acrobatics - Unused - result.getInt(OFFSET_DATS + 11)
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 {
mobHealthbarType = MobHealthbarType.valueOf(result.getString(OFFSET_OTHER + 2));
}
@@ -1211,7 +1233,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
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) {

View File

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

View File

@@ -1,79 +1,19 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.inventory.ItemStack;
public class CustomBlock {
private int itemID;
private byte dataValue;
private int xpGain;
private int tier;
private ItemStack itemDrop;
private int minimumDropAmount;
private int maximumDropAmount;
private boolean canDoubleDrop;
public CustomBlock(int minimumDropAmount, int maximumDropAmount, ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
this.itemID = itemID;
this.dataValue = dataValue;
public CustomBlock(int xpGain, boolean canDoubleDrop) {
this.xpGain = xpGain;
this.tier = tier;
this.itemDrop = itemDrop;
this.minimumDropAmount = minimumDropAmount;
this.maximumDropAmount = maximumDropAmount;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public byte getDataValue() {
return dataValue;
}
public void setDataValue(byte dataValue) {
this.dataValue = dataValue;
this.canDoubleDrop = canDoubleDrop;
}
public int getXpGain() {
return xpGain;
}
public void setXpGain(int xpGain) {
this.xpGain = xpGain;
}
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
public ItemStack getItemDrop() {
return itemDrop;
}
public void setItemDrop(ItemStack itemDrop) {
this.itemDrop = itemDrop;
}
public int getMinimumDropAmount() {
return minimumDropAmount;
}
public void setMinimumDropAmount(int minimumDropAmount) {
this.minimumDropAmount = minimumDropAmount;
}
public int getMaximumDropAmount() {
return maximumDropAmount;
}
public void setMaximumDropAmount(int maximumDropAmount) {
this.maximumDropAmount = maximumDropAmount;
public boolean isDoubleDropEnabled() {
return canDoubleDrop;
}
}

View File

@@ -1,11 +1,8 @@
package com.gmail.nossr50.datatypes.mods;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class CustomEntity {
private int entityID;
private EntityType entityType;
private double xpMultiplier;
private boolean canBeTamed;
private int tamingXP;
@@ -13,9 +10,7 @@ public class CustomEntity {
private ItemStack callOfTheWildItem;
private int callOfTheWildAmount;
public CustomEntity(int entityID, EntityType entityType, double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.entityID = entityID;
this.entityType = entityType;
public CustomEntity(double xpMultiplier, boolean canBeTamed, int tamingXP, boolean canBeSummoned, ItemStack callOfTheWildItem, int callOfTheWildAmount) {
this.xpMultiplier = xpMultiplier;
this.canBeTamed = canBeTamed;
this.tamingXP = tamingXP;
@@ -24,67 +19,27 @@ public class CustomEntity {
this.callOfTheWildAmount = callOfTheWildAmount;
}
public int getEntityID() {
return entityID;
}
public void setEntityID(int entityID) {
this.entityID = entityID;
}
public EntityType getEntityType() {
return entityType;
}
public void setEntityType(EntityType entityType) {
this.entityType = entityType;
}
public double getXpMultiplier() {
return xpMultiplier;
}
public void setXpMultiplier(double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
}
public boolean isCanBeTamed() {
public boolean canBeTamed() {
return canBeTamed;
}
public void setCanBeTamed(boolean canBeTamed) {
this.canBeTamed = canBeTamed;
}
public int getTamingXP() {
return tamingXP;
}
public void setTamingXP(int tamingXP) {
this.tamingXP = tamingXP;
}
public boolean isCanBeSummoned() {
public boolean canBeSummoned() {
return canBeSummoned;
}
public void setCanBeSummoned(boolean canBeSummoned) {
this.canBeSummoned = canBeSummoned;
}
public ItemStack getCallOfTheWildItem() {
return callOfTheWildItem;
}
public void setCallOfTheWildItem(ItemStack callOfTheWildItem) {
this.callOfTheWildItem = callOfTheWildItem;
}
public int getCallOfTheWildAmount() {
return callOfTheWildAmount;
}
public void setCallOfTheWildAmount(int callOfTheWildAmount) {
this.callOfTheWildAmount = callOfTheWildAmount;
}
}

View File

@@ -1,27 +0,0 @@
package com.gmail.nossr50.datatypes.mods;
public class CustomItem {
protected int itemID;
protected short durability;
public CustomItem(int itemID, short durability) {
this.itemID = itemID;
this.durability = durability;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public short getDurability() {
return durability;
}
public void setDurability(short durability) {
this.durability = durability;
}
}

View File

@@ -1,12 +1,11 @@
package com.gmail.nossr50.datatypes.mods;
public class CustomTool extends CustomItem {
public class CustomTool {
private double xpMultiplier;
private boolean abilityEnabled;
private int tier;
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier, short durability, int itemID) {
super(itemID, durability);
public CustomTool(int tier, boolean abilityEnabled, double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
this.abilityEnabled = abilityEnabled;
this.tier = tier;
@@ -16,23 +15,11 @@ public class CustomTool extends CustomItem {
return xpMultiplier;
}
public void setXpMultiplier(Double xpMultiplier) {
this.xpMultiplier = xpMultiplier;
}
public boolean isAbilityEnabled() {
return abilityEnabled;
}
public void setAbilityEnabled(boolean abilityEnabled) {
this.abilityEnabled = abilityEnabled;
}
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
}

View File

@@ -67,14 +67,14 @@ public class Party {
return onlineMembers;
}
public String getLeader() {
return leader;
}
public String getName() {
return name;
}
public String getLeader() {
return leader;
}
public String getPassword() {
return password;
}

View File

@@ -6,9 +6,15 @@ import java.util.Set;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.mods.CustomTool;
@@ -16,12 +22,11 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.ArcheryManager;
@@ -38,9 +43,12 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
@@ -78,6 +86,8 @@ public class McMMOPlayer {
private int lastSalvageClick;
private boolean godMode;
private Location hookLocation;
private final Map<AbilityType, Boolean> abilityMode = new HashMap<AbilityType, Boolean>();
private final Map<AbilityType, Boolean> abilityInformed = new HashMap<AbilityType, Boolean>();
@@ -87,6 +97,7 @@ public class McMMOPlayer {
private int recentlyHurt;
private int respawnATS;
private int teleportATS;
private long databaseATS;
private int chimeraWingLastUse;
private Location teleportCommence;
@@ -123,6 +134,69 @@ public class McMMOPlayer {
toolMode.put(toolType, false);
toolATS.put(toolType, 0);
}
if (!profile.isLoaded()) {
mcMMO.p.getLogger().warning("Unable to load the PlayerProfile for " + playerName + ". Will retry over the next several seconds.");
new RetryProfileLoadingTask().runTaskTimerAsynchronously(mcMMO.p, 11L, 31L);
}
}
private class RetryProfileLoadingTask extends BukkitRunnable {
private static final int MAX_TRIES = 5;
private final String playerName = McMMOPlayer.this.player.getName();
private int attempt = 0;
// WARNING: ASYNC TASK
// DO NOT MODIFY THE McMMOPLAYER FROM THIS CODE
@Override
public void run() {
// Quit if they logged out
if (!player.isOnline()) {
mcMMO.p.getLogger().info("Aborting profile loading recovery for " + playerName + " - player logged out");
this.cancel();
return;
}
// Send the message that we're doing the recovery
if (attempt == 0) {
player.sendMessage(LocaleLoader.getString("Recovery.Notice"));
}
// Increment attempt counter and try
attempt++;
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
// If successful, schedule the apply
if (profile.isLoaded()) {
new ApplySuccessfulProfile(profile).runTask(mcMMO.p);
player.sendMessage(LocaleLoader.getString("Recovery.Success"));
this.cancel();
return;
}
// If we've failed five times, give up
if (attempt >= MAX_TRIES) {
mcMMO.p.getLogger().severe("Giving up on attempting to load the PlayerProfile for " + playerName);
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Recovery.AdminFailureNotice", playerName), Server.BROADCAST_CHANNEL_ADMINISTRATIVE);
player.sendMessage(LocaleLoader.getString("Recovery.Failure").split("\n"));
this.cancel();
return;
}
}
}
private class ApplySuccessfulProfile extends BukkitRunnable {
private final PlayerProfile profile;
private ApplySuccessfulProfile(PlayerProfile profile) {
this.profile = profile;
}
// Synchronized task
// No database access permitted
@Override
public void run() {
McMMOPlayer.this.profile = profile;
}
}
public AcrobaticsManager getAcrobaticsManager() {
@@ -354,28 +428,36 @@ public class McMMOPlayer {
teleportATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
public long getDatabaseATS() {
return databaseATS;
}
public void actualizeDatabaseATS() {
databaseATS = System.currentTimeMillis();
}
/*
* Repair Anvil Placement
*/
public boolean getPlacedAnvil(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public boolean getPlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return placedRepairAnvil;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
return placedSalvageAnvil;
}
return true;
}
public void togglePlacedAnvil(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public void togglePlacedAnvil(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
placedRepairAnvil = !placedRepairAnvil;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
placedSalvageAnvil = !placedSalvageAnvil;
}
}
@@ -384,34 +466,34 @@ public class McMMOPlayer {
* Repair Anvil Usage
*/
public int getLastAnvilUse(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public int getLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
return lastRepairClick;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
return lastSalvageClick;
}
return 0;
}
public void setLastAnvilUse(int anvilId, int value) {
if (anvilId == Repair.repairAnvilId) {
public void setLastAnvilUse(Material anvilType, int value) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = value;
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = value;
}
}
public void actualizeLastAnvilUse(int anvilId) {
if (anvilId == Repair.repairAnvilId) {
public void actualizeLastAnvilUse(Material anvilType) {
if (anvilType == Repair.repairAnvilMaterial) {
lastRepairClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
if (anvilId == Repair.salvageAnvilId) {
if (anvilType == Repair.salvageAnvilMaterial) {
lastSalvageClick = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
}
@@ -428,6 +510,18 @@ public class McMMOPlayer {
godMode = !godMode;
}
/*
* Fishing: Master Angler
*/
public Location getHookLocation() {
return hookLocation;
}
public void setHookLocation(Location hookLocation) {
this.hookLocation = hookLocation;
}
/*
* Skill notifications
*/
@@ -448,8 +542,8 @@ public class McMMOPlayer {
public int getPowerLevel() {
int powerLevel = 0;
for (SkillType type : SkillType.nonChildSkills()) {
if (Permissions.skillEnabled(player, type)) {
for (SkillType type : SkillType.NON_CHILD_SKILLS) {
if (type.getPermissions(player)) {
powerLevel += profile.getSkillLevel(type);
}
}
@@ -472,7 +566,7 @@ public class McMMOPlayer {
Set<SkillType> parentSkills = FamilyTree.getParents(skillType);
for (SkillType parentSkill : parentSkills) {
if (Permissions.skillEnabled(player, parentSkill)) {
if (parentSkill.getPermissions(player)) {
beginXpGain(parentSkill, xp / parentSkills.size());
}
}
@@ -507,7 +601,7 @@ public class McMMOPlayer {
* @param xp Experience amount to add
*/
public void applyXpGain(SkillType skillType, float xp) {
if (!Permissions.skillEnabled(player, skillType)) {
if (!skillType.getPermissions(player)) {
return;
}
@@ -521,23 +615,45 @@ public class McMMOPlayer {
return;
}
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
if (!EventUtils.handleXpGainEvent(player, skillType, xp)) {
return;
}
profile.setSkillXpLevel(skillType, profile.getSkillXpLevelRaw(skillType) + event.getRawXpGained());
McMMOHud spoutHud = profile.getSpoutHud();
if (spoutHud != null) {
spoutHud.setLastGained(skillType);
}
isUsingUnarmed = (skillType == SkillType.UNARMED);
SkillUtils.xpCheckSkill(skillType, player, profile);
checkXp(skillType);
}
/**
* Check the XP of a skill.
*
* @param skillType The skill to check
*/
private void checkXp(SkillType skillType) {
int levelsGained = 0;
float xpRemoved = 0;
if (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
while (profile.getSkillXpLevelRaw(skillType) >= profile.getXpToLevel(skillType)) {
if ((skillType.getMaxLevel() >= profile.getSkillLevel(skillType) + 1) && (Config.getInstance().getPowerLevelCap() >= getPowerLevel() + 1)) {
int xp = profile.getXpToLevel(skillType);
xpRemoved += xp;
profile.removeXp(skillType, xp);
levelsGained++;
profile.skillUp(skillType, 1);
}
else {
profile.addLevels(skillType, 0); // This seems kinda pointless... why do we have this again?
}
}
if (!EventUtils.handleLevelChangeEvent(player, skillType, levelsGained, xpRemoved, true)) {
return;
}
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, profile.getSkillLevel(skillType)));
}
}
/*
@@ -722,4 +838,119 @@ public class McMMOPlayer {
player.sendMessage(LocaleLoader.getString("Party.Forbidden"));
}
}
/**
* Check to see if an ability can be activated.
*
* @param skill The skill the ability is based on
*/
public void checkAbilityActivation(SkillType skill) {
ToolType tool = skill.getTool();
AbilityType ability = skill.getAbility();
setToolPreparationMode(tool, false);
if (getAbilityMode(ability)) {
return;
}
int timeRemaining = calculateTimeRemaining(ability);
if (timeRemaining > 0) {
/*
* Axes and Woodcutting are odd because they share the same tool.
* We show them the too tired message when they take action.
*/
if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
}
return;
}
if (EventUtils.callPlayerAbilityActivateEvent(player, skill).isCancelled()) {
return;
}
int ticks = PerksUtils.handleActivationPerks(player, 2 + (profile.getSkillLevel(skill) / AdvancedConfig.getInstance().getAbilityLength()), ability.getMaxLength());
// Notify people that ability has been activated
ParticleEffectUtils.playAbilityEnabledEffect(player);
if (useChatNotifications()) {
player.sendMessage(ability.getAbilityOn());
}
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayer(player));
// Enable the ability
profile.setSkillDATS(ability, System.currentTimeMillis() + (ticks * Misc.TIME_CONVERSION_FACTOR));
setAbilityMode(ability, true);
if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER) {
SkillUtils.handleAbilitySpeedIncrease(player);
}
new AbilityDisableTask(this, ability).runTaskLater(mcMMO.p, ticks * Misc.TICK_CONVERSION_FACTOR);
}
public void processAbilityActivation(SkillType skill) {
if (Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && !player.isSneaking()) {
return;
}
ItemStack inHand = player.getItemInHand();
if (ModUtils.isCustomTool(inHand) && !ModUtils.getToolFromItemStack(inHand).isAbilityEnabled()) {
return;
}
if (!getAbilityUse()) {
return;
}
for (AbilityType abilityType : AbilityType.values()) {
if (getAbilityMode(abilityType)) {
return;
}
}
AbilityType ability = skill.getAbility();
ToolType tool = skill.getTool();
/*
* Woodcutting & Axes need to be treated differently.
* Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
*/
if (ability.getPermissions(player) && tool.inHand(inHand) && !getToolPreparationMode(tool)) {
if (skill != SkillType.WOODCUTTING && skill != SkillType.AXES) {
int timeRemaining = calculateTimeRemaining(ability);
if (!getAbilityMode(ability) && timeRemaining > 0) {
player.sendMessage(LocaleLoader.getString("Skills.TooTired", timeRemaining));
return;
}
}
if (Config.getInstance().getAbilityMessagesEnabled()) {
player.sendMessage(tool.getRaiseTool());
}
setToolPreparationATS(tool, System.currentTimeMillis());
setToolPreparationMode(tool, true);
new ToolLowerTask(this, tool).runTaskLaterAsynchronously(mcMMO.p, 4 * Misc.TICK_CONVERSION_FACTOR);
}
}
/**
* Calculate the time remaining until the ability's cooldown expires.
*
* @param ability AbilityType whose cooldown to check
*
* @return the number of seconds remaining before the cooldown expires
*/
public int calculateTimeRemaining(AbilityType ability) {
long deactivatedTimestamp = profile.getSkillDATS(ability) * Misc.TIME_CONVERSION_FACTOR;
return (int) (((deactivatedTimestamp + (PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TIME_CONVERSION_FACTOR)) - System.currentTimeMillis()) / Misc.TIME_CONVERSION_FACTOR);
}
}

View File

@@ -9,13 +9,10 @@ import org.bukkit.scoreboard.Scoreboard;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.datatypes.spout.huds.McMMOHud;
import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.player.UserManager;
@@ -25,9 +22,7 @@ public class PlayerProfile {
private boolean changed;
/* HUDs */
private HudType hudType;
private MobHealthbarType mobHealthbarType;
private McMMOHud spoutHud;
private Scoreboard playerStatsScoreboard;
/* Skill Data */
@@ -38,14 +33,13 @@ public class PlayerProfile {
public PlayerProfile(String playerName) {
this.playerName = playerName;
hudType = mcMMO.isSpoutEnabled() ? SpoutConfig.getInstance().getDefaultHudType() : HudType.DISABLED;
mobHealthbarType = Config.getInstance().getMobHealthbarDefault();
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
}
for (SkillType skillType : SkillType.nonChildSkills()) {
for (SkillType skillType : SkillType.NON_CHILD_SKILLS) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0F);
}
@@ -59,10 +53,9 @@ public class PlayerProfile {
/**
* Calling this constructor is considered loading the profile.
*/
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, HudType hudType, MobHealthbarType mobHealthbarType) {
this(playerName, true);
public PlayerProfile(String playerName, Map<SkillType, Integer> argSkills, Map<SkillType, Float> argSkillsXp, Map<AbilityType, Integer> argSkillsDats, MobHealthbarType mobHealthbarType) {
this(playerName);
this.hudType = hudType;
this.mobHealthbarType = mobHealthbarType;
this.skills.putAll(argSkills);
@@ -73,12 +66,14 @@ public class PlayerProfile {
}
public void save() {
if (!changed) {
if (!changed || !loaded) {
return;
}
mcMMO.getDatabaseManager().saveUser(this);
changed = false;
changed = !mcMMO.getDatabaseManager().saveUser(this);
if (changed) {
mcMMO.p.getLogger().warning("PlayerProfile for " + playerName + " failed to save");
}
}
public String getPlayerName() {
@@ -89,26 +84,6 @@ public class PlayerProfile {
return loaded;
}
/*
* HUD Stuff
*/
public HudType getHudType() {
return hudType;
}
public McMMOHud getSpoutHud() {
return spoutHud;
}
public void setSpoutHud(McMMOHud spoutHud) {
this.spoutHud = spoutHud;
}
public void setHudType(HudType hudType) {
this.hudType = hudType;
}
/*
* Mob Healthbars
*/
@@ -177,11 +152,7 @@ public class PlayerProfile {
*/
public int getSkillLevel(SkillType skillType) {
if (skillType.isChildSkill()) {
return getChildSkillLevel(skillType);
}
return skills.get(skillType);
return skillType.isChildSkill() ? getChildSkillLevel(skillType) : skills.get(skillType);
}
public float getSkillXpLevelRaw(SkillType skillType) {

View File

@@ -1,14 +1,19 @@
package com.gmail.nossr50.datatypes.skills;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.google.common.collect.ImmutableList;
public enum AbilityType {
BERSERK(
@@ -60,6 +65,9 @@ public enum AbilityType {
"Swords.Skills.SS.Refresh",
"Swords.Skills.SS.Other.Off"),
/**
* Has cooldown - but has to share a skill with Super Breaker, so needs special treatment
*/
BLAST_MINING(
null,
null,
@@ -67,19 +75,15 @@ public enum AbilityType {
"Mining.Blast.Refresh",
null),
LEAF_BLOWER(
null,
null,
null,
null,
null),
/**
* No cooldown - always active
*/
LEAF_BLOWER,
BLOCK_CRACKER(
null,
null,
null,
null,
null);
/**
* Not a first-class Ability - part of Berserk
*/
BLOCK_CRACKER;
private String abilityOn;
private String abilityOff;
@@ -87,6 +91,20 @@ public enum AbilityType {
private String abilityRefresh;
private String abilityPlayerOff;
/**
* Those abilities that have a cooldown saved to the database.
*/
public static final List<AbilityType> NORMAL_ABILITIES = ImmutableList.of(BERSERK, BLAST_MINING, GIGA_DRILL_BREAKER, GREEN_TERRA, SERRATED_STRIKES, SKULL_SPLITTER, SUPER_BREAKER, TREE_FELLER);
/**
* Those abilities that do not have a cooldown saved to the database.
*/
public static final List<AbilityType> NON_NORMAL_ABILITIES = ImmutableList.of(BLOCK_CRACKER, LEAF_BLOWER);
private AbilityType() {
this(null, null, null, null, null);
}
private AbilityType(String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
@@ -99,8 +117,8 @@ public enum AbilityType {
return Config.getInstance().getCooldown(this);
}
public int getMaxTicks() {
return Config.getInstance().getMaxTicks(this);
public int getMaxLength() {
return Config.getInstance().getMaxLength(this);
}
public String getAbilityOn() {
@@ -123,6 +141,10 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh);
}
public String getName() {
return StringUtils.getPrettyAbilityString(this);
}
@Override
public String toString() {
String baseString = name();
@@ -220,4 +242,23 @@ public enum AbilityType {
return false;
}
}
/**
* Check to see if ability should be triggered.
*
* @param player The player using the ability
* @param block The block modified by the ability
* @return true if the ability should activate, false otherwise
*/
public boolean triggerCheck(Player player, Block block) {
switch (this) {
case BERSERK:
case BLOCK_CRACKER:
case LEAF_BLOWER:
return blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true);
default:
return false;
}
}
}

View File

@@ -5,6 +5,7 @@ import java.util.Collections;
import java.util.List;
import org.bukkit.Color;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
@@ -24,8 +25,8 @@ import com.gmail.nossr50.skills.swords.SwordsManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import com.google.common.collect.ImmutableList;
@@ -51,15 +52,34 @@ public enum SkillType {
public static final List<String> SKILL_NAMES;
public static final List<SkillType> CHILD_SKILLS;
public static final List<SkillType> NON_CHILD_SKILLS;
public static final List<SkillType> COMBAT_SKILLS = ImmutableList.of(ARCHERY, AXES, SWORDS, TAMING, UNARMED);
public static final List<SkillType> GATHERING_SKILLS = ImmutableList.of(EXCAVATION, FISHING, HERBALISM, MINING, WOODCUTTING);
public static final List<SkillType> MISC_SKILLS = ImmutableList.of(ACROBATICS, REPAIR, SMELTING);
static {
List<SkillType> childSkills = new ArrayList<SkillType>();
List<SkillType> nonChildSkills = new ArrayList<SkillType>();
ArrayList<String> names = new ArrayList<String>();
for (SkillType skill : values()) {
names.add(SkillUtils.getSkillName(skill));
if (skill.isChildSkill()) {
childSkills.add(skill);
}
else {
nonChildSkills.add(skill);
}
names.add(skill.getName());
}
Collections.sort(names);
SKILL_NAMES = ImmutableList.copyOf(names);
CHILD_SKILLS = ImmutableList.copyOf(childSkills);
NON_CHILD_SKILLS = ImmutableList.copyOf(nonChildSkills);
}
private SkillType(Class<? extends SkillManager> managerClass, Color runescapeColor) {
@@ -109,10 +129,18 @@ public enum SkillType {
return Config.getInstance().getHardcoreStatLossEnabled(this);
}
public void setHardcoreStatLossEnabled(boolean enable) {
Config.getInstance().setHardcoreStatLossEnabled(this, enable);
}
public boolean getHardcoreVampirismEnabled() {
return Config.getInstance().getHardcoreVampirismEnabled(this);
}
public void setHardcoreVampirismEnabled(boolean enable) {
Config.getInstance().setHardcoreVampirismEnabled(this, enable);
}
public ToolType getTool() {
return tool;
}
@@ -143,33 +171,14 @@ public enum SkillType {
// TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them
public boolean isChildSkill() {
switch (this) {
case SMELTING:
return true;
case SMELTING:
return true;
default:
return false;
default:
return false;
}
}
public static SkillType[] nonChildSkills() {
return new SkillType[] {SkillType.ACROBATICS,
SkillType.ARCHERY,
SkillType.AXES,
SkillType.EXCAVATION,
SkillType.FISHING,
SkillType.HERBALISM,
SkillType.MINING,
SkillType.REPAIR,
SkillType.SWORDS,
SkillType.TAMING,
SkillType.UNARMED,
SkillType.WOODCUTTING };
}
public static SkillType[] childSkills() {
return new SkillType[] { SkillType.SMELTING };
}
public Color getRunescapeModeColor() {
return runescapeColor;
}
@@ -183,4 +192,12 @@ public enum SkillType {
return null;
}
public String getName() {
return Config.getInstance().getLocale().equalsIgnoreCase("en_US") ? StringUtils.getCapitalized(this.toString()) : StringUtils.getCapitalized(LocaleLoader.getString(StringUtils.getCapitalized(this.toString()) + ".SkillName"));
}
public boolean getPermissions(Player player) {
return Permissions.skillEnabled(player, this);
}
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,305 +0,0 @@
package com.gmail.nossr50.datatypes.spout.popups;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.spout.SpoutConfig;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.spout.huds.HudType;
import com.gmail.nossr50.util.StringUtils;
import org.getspout.spoutapi.gui.Color;
import org.getspout.spoutapi.gui.GenericGradient;
import org.getspout.spoutapi.gui.GenericTexture;
import org.getspout.spoutapi.gui.InGameHUD;
import org.getspout.spoutapi.gui.RenderPriority;
import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
public class McMMOXpBar {
private SpoutPlayer spoutPlayer;
private Widget xpBar;
private GenericGradient xpFill;
private GenericGradient xpBackground;
private GenericGradient xpIconBackground;
private GenericGradient xpIconBorder;
private GenericTexture xpIcon;
public McMMOXpBar(SpoutPlayer spoutPlayer, HudType hudType) {
this.spoutPlayer = spoutPlayer;
switch (hudType) {
case RETRO:
initializeXpBarRetro();
break;
case STANDARD:
initializeXpBarStandard();
break;
case SMALL:
initializeXpBarSmall();
break;
case DISABLED:
break;
default:
break;
}
spoutPlayer.getMainScreen().setDirty(true);
}
public void removeWidgets() {
InGameHUD inGameHud = spoutPlayer.getMainScreen();
if (xpBar != null) {
inGameHud.removeWidget(xpBar);
}
if (xpFill != null) {
inGameHud.removeWidget(xpFill);
}
if (xpBackground != null) {
inGameHud.removeWidget(xpBackground);
}
if (xpIconBackground != null) {
inGameHud.removeWidget(xpIconBackground);
}
if (xpIconBorder != null) {
inGameHud.removeWidget(xpIconBorder);
}
if (xpIcon != null) {
inGameHud.removeWidget(xpIcon);
}
}
/**
* Initialize Retro XP bar.
*/
private void initializeXpBarRetro() {
Color border = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBorderRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBorderBlue(), 1f);
Color green = new Color(0f, 1f, 0f, 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
xpBar = new GenericGradient();
xpFill = new GenericGradient();
xpBackground = new GenericGradient();
xpBar.setWidth(128);
xpBar.setHeight(4);
xpBar.setX(149);
xpBar.setY(10);
((GenericGradient) xpBar).setBottomColor(border);
((GenericGradient) xpBar).setTopColor(border);
xpBar.setPriority(RenderPriority.Highest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
xpFill.setWidth(0);
xpFill.setHeight(2);
xpFill.setX(150);
xpFill.setY(11);
xpFill.setBottomColor(green);
xpFill.setTopColor(green);
xpFill.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpFill);
xpBackground.setWidth(126);
xpBackground.setHeight(2);
xpBackground.setX(150);
xpBackground.setY(11);
xpBackground.setBottomColor(background);
xpBackground.setTopColor(background);
xpBackground.setPriority(RenderPriority.Low);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBackground);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpIconBackground = new GenericGradient();
xpIconBorder = new GenericGradient();
xpIcon = new GenericTexture();
xpIconBackground.setBottomColor(darkbg);
xpIconBackground.setTopColor(darkbg);
xpIconBackground.setWidth(4);
xpIconBackground.setHeight(4);
xpIconBackground.setPriority(RenderPriority.High);
xpIconBackground.setX(142);
xpIconBackground.setY(10);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBackground);
xpIconBorder.setBottomColor(border);
xpIconBorder.setTopColor(border);
xpIconBorder.setWidth(6);
xpIconBorder.setHeight(6);
xpIconBorder.setPriority(RenderPriority.Highest);
xpIconBorder.setX(141);
xpIconBorder.setY(9);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIconBorder);
xpIcon.setWidth(6);
xpIcon.setHeight(6);
xpIcon.setX(141);
xpIcon.setY(9);
xpIcon.setPriority(RenderPriority.Normal);
xpIcon.setUrl("Icon_r.png");
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Standard XP bar.
*/
private void initializeXpBarStandard() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(8);
xpBar.setWidth(256);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(16);
xpIcon.setWidth(32);
xpIcon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Initialize Small XP bar.
*/
private void initializeXpBarSmall() {
xpBar = new GenericTexture();
((GenericTexture) xpBar).setUrl("xpbar_inc000.png");
xpBar.setX(427 / 2 - 64);
xpBar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpBar.setHeight(4);
xpBar.setWidth(128);
xpBar.setPriority(RenderPriority.Lowest);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpBar);
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpIcon = new GenericTexture();
xpIcon.setUrl("Icon.png");
xpIcon.setHeight(8);
xpIcon.setWidth(16);
xpIcon.setX(427 / 2 - (8 + 64));
xpIcon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpIcon.setPriority(RenderPriority.High);
spoutPlayer.getMainScreen().attachWidget(mcMMO.p, xpIcon);
}
}
/**
* Update the XP bar.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
public void update(SkillType skillType, PlayerProfile playerProfile) {
switch (playerProfile.getHudType()) {
case RETRO:
updateXpBarRetro(skillType, playerProfile);
break;
case STANDARD:
case SMALL:
updateXpBarStandard(skillType, playerProfile);
break;
case DISABLED:
break;
default:
break;
}
}
/**
* Update XP bar for Standard & Small styles.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
private void updateXpBarStandard(SkillType skillType, PlayerProfile playerProfile) {
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + ".png");
((GenericTexture) xpBar).setUrl(getUrlBar(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.STANDARD)));
spoutPlayer.getMainScreen().setDirty(true);
}
/**
* Update XP bar for Retro styles.
*
* @param skillType The skill last used
* @param playerProfile The profile of the player whose XP bar should be updated
*/
private void updateXpBarRetro(SkillType skillType, PlayerProfile playerProfile) {
Color color = getRetroColor(skillType);
xpIcon.setUrl(StringUtils.getCapitalized(skillType.toString()) + "_r.png");
xpFill.setBottomColor(color);
xpFill.setTopColor(color);
xpFill.setWidth(getXpInc(playerProfile.getSkillXpLevel(skillType), playerProfile.getXpToLevel(skillType), HudType.RETRO));
spoutPlayer.getMainScreen().setDirty(true);
}
private static Color getRetroColor(SkillType type) {
return new Color((float) SpoutConfig.getInstance().getRetroHUDRed(type), (float) SpoutConfig.getInstance().getRetroHUDGreen(type), (float) SpoutConfig.getInstance().getRetroHUDBlue(type), 1f);
}
private static String getUrlBar(Integer number) {
char[] num = number.toString().toCharArray();
switch (num.length) {
case 1:
return "xpbar_inc00" + number + ".png";
case 2:
return "xpbar_inc0" + number + ".png";
default:
return "xpbar_inc" + number + ".png";
}
}
private static Integer getXpInc(int skillXp, int xpToLevel, HudType hudType) {
double percentage = (double) skillXp / xpToLevel;
double inc;
switch (hudType) {
case RETRO:
inc = 0.0079365079365079;
break;
case STANDARD:
inc = 0.0039370078740157;
break;
default:
return 1;
}
return (int) (percentage / inc);
}
}

View File

@@ -0,0 +1,29 @@
package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.enchantments.Enchantment;
public class EnchantmentTreasure {
private Enchantment enchantment;
private int level;
public EnchantmentTreasure(Enchantment enchantment, int level) {
this.setEnchantment(enchantment);
this.setLevel(level);
}
public Enchantment getEnchantment() {
return enchantment;
}
public void setEnchantment(Enchantment enchantment) {
this.enchantment = enchantment;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
this.level = level;
}
}

View File

@@ -3,138 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class ExcavationTreasure extends Treasure {
// dirt | grass | sand | gravel | clay | mycel | soulsand | snow
// 00000001 - dirt 1
// 00000010 - grass 2
// 00000100 - sand 4
// 00001000 - gravel 8
// 00010000 - clay 16
// 00100000 - mycel 32
// 01000000 - soulsand 64
// 10000000 - snow 128
private byte dropsFrom = 0x0;
public ExcavationTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromDirt() {
return getDropFromMask(1);
}
public boolean getDropsFromGrass() {
return getDropFromMask(2);
}
public boolean getDropsFromSand() {
return getDropFromMask(4);
}
public boolean getDropsFromGravel() {
return getDropFromMask(8);
}
public boolean getDropsFromClay() {
return getDropFromMask(16);
}
public boolean getDropsFromMycel() {
return getDropFromMask(32);
}
public boolean getDropsFromSoulSand() {
return getDropFromMask(64);
}
public boolean getDropsFromSnow() {
return getDropFromMask(128);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromDirt() {
setDropFromMask(1);
}
public void setDropsFromGrass() {
setDropFromMask(2);
}
public void setDropsFromSand() {
setDropFromMask(4);
}
public void setDropsFromGravel() {
setDropFromMask(8);
}
public void setDropsFromClay() {
setDropFromMask(16);
}
public void setDropsFromMycel() {
setDropFromMask(32);
}
public void setDropsFromSoulSand() {
setDropFromMask(64);
}
public void setDropsFromSnow() {
setDropFromMask(128);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromDirt() {
unsetDropFromMask(1);
}
public void unsetDropsFromGrass() {
unsetDropFromMask(2);
}
public void unsetDropsFromSand() {
unsetDropFromMask(4);
}
public void unsetDropsFromGravel() {
unsetDropFromMask(8);
}
public void unsetDropsFromClay() {
unsetDropFromMask(16);
}
public void unsetDropsFromMycel() {
unsetDropFromMask(32);
}
public void unsetDropsFromSoulSand() {
unsetDropFromMask(64);
}
public void unsetDropsFromSnow() {
unsetDropFromMask(128);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
}

View File

@@ -3,18 +3,8 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class FishingTreasure extends Treasure {
private int maxLevel;
public FishingTreasure(ItemStack drop, int xp, Double dropChance, int dropLevel, int maxLevel) {
super(drop, xp, dropChance, dropLevel);
this.setMaxLevel(maxLevel);
}
public int getMaxLevel() {
return maxLevel;
}
public void setMaxLevel(int maxLevel) {
this.maxLevel = maxLevel;
public FishingTreasure(ItemStack drop, int xp) {
super(drop, xp, 0, 0);
}
}

View File

@@ -3,73 +3,7 @@ package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.inventory.ItemStack;
public class HylianTreasure extends Treasure {
// bushes | flowers | pots
// 00000001 - bushes 1
// 00000010 - flowers 2
// 00000100 - pots 4
private byte dropsFrom = 0x0;
public HylianTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
}
// Raw getters and setters
public byte getDropsFrom() {
return dropsFrom;
}
public void setDropsFrom(byte dropsFrom) {
this.dropsFrom = dropsFrom;
}
// Getters
public boolean getDropsFromBushes() {
return getDropFromMask(1);
}
public boolean getDropsFromFlowers() {
return getDropFromMask(2);
}
public boolean getDropsFromPots() {
return getDropFromMask(4);
}
private boolean getDropFromMask(int mask) {
return ((dropsFrom & mask) > 0) ? true : false;
}
// Setters
public void setDropsFromBushes() {
setDropFromMask(1);
}
public void setDropsFromFlowers() {
setDropFromMask(2);
}
public void setDropsFromPots() {
setDropFromMask(4);
}
private void setDropFromMask(int mask) {
dropsFrom |= mask;
}
// Un-setters
public void unsetDropsFromBushes() {
unsetDropFromMask(1);
}
public void unsetDropsFromFlowers() {
unsetDropFromMask(2);
}
public void unsetDropsFromPots() {
unsetDropFromMask(4);
}
private void unsetDropFromMask(int mask) {
dropsFrom &= ~mask;
}
}

View File

@@ -0,0 +1,20 @@
package com.gmail.nossr50.datatypes.treasure;
public enum Rarity {
RECORD,
LEGENDARY,
EPIC,
RARE,
UNCOMMON,
COMMON,
TRAP;
public static Rarity getRarity(String string) {
try {
return valueOf(string);
}
catch (IllegalArgumentException ex) {
return COMMON;
}
}
};

View File

@@ -1,21 +1,9 @@
package com.gmail.nossr50.datatypes.treasure;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
public class ShakeTreasure extends Treasure {
private EntityType mob;
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel, EntityType mob) {
public ShakeTreasure(ItemStack drop, int xp, double dropChance, int dropLevel) {
super(drop, xp, dropChance, dropLevel);
this.mob = mob;
}
public EntityType getMob() {
return mob;
}
public void setMob(EntityType mob) {
this.mob = mob;
}
}

View File

@@ -3,28 +3,16 @@ package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerSkillEvent implements Cancellable {
private AbilityType abilityType;
public class McMMOPlayerAbilityActivateEvent extends McMMOPlayerAbilityEvent implements Cancellable {
private boolean cancelled;
public McMMOPlayerAbilityActivateEvent(Player player, SkillType skill) {
super(player, skill);
abilityType = skill.getAbility();
cancelled = false;
}
/**
* @return The ability type involved in this event
*/
public AbilityType getAbilityType() {
return abilityType;
}
public boolean isCancelled() {
return cancelled;
}

View File

@@ -2,21 +2,10 @@ package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerSkillEvent {
private AbilityType ability;
public class McMMOPlayerAbilityDeactivateEvent extends McMMOPlayerAbilityEvent {
public McMMOPlayerAbilityDeactivateEvent(Player player, SkillType skill) {
super(player, skill);
this.ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}
}

View File

@@ -0,0 +1,20 @@
package com.gmail.nossr50.events.skills.abilities;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerAbilityEvent extends McMMOPlayerSkillEvent {
private AbilityType ability;
protected McMMOPlayerAbilityEvent(Player player, SkillType skill) {
super(player, skill);
ability = skill.getAbility();
}
public AbilityType getAbility() {
return ability;
}
}

View File

@@ -0,0 +1,24 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled;
protected McMMOPlayerFishingEvent(Player player) {
super(player, SkillType.FISHING);
cancelled = false;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
}

View File

@@ -1,20 +1,14 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerFishingEvent {
private ItemStack treasure;
private int xp;
public McMMOPlayerFishingTreasureEvent(Player player, ItemStack treasure, int xp) {
super(player, SkillType.FISHING);
super(player);
this.treasure = treasure;
this.xp = xp;
}
@@ -27,14 +21,6 @@ public class McMMOPlayerFishingTreasureEvent extends McMMOPlayerSkillEvent imple
this.treasure = item;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public int getXp() {
return xp;
}

View File

@@ -7,7 +7,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class McMMOPlayerMagicHunterEvent extends McMMOPlayerFishingTreasureEvent {
private Map<Enchantment, Integer> enchants;
public McMMOPlayerMagicHunterEvent(Player player, ItemStack treasure, int xp, Map<Enchantment, Integer> enchants) {

View File

@@ -1,30 +1,16 @@
package com.gmail.nossr50.events.skills.fishing;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Cancellable {
private boolean cancelled = false;
public class McMMOPlayerShakeEvent extends McMMOPlayerFishingEvent {
private ItemStack drop;
public McMMOPlayerShakeEvent(Player player, ItemStack drop) {
super(player, SkillType.FISHING);
super(player);
this.drop = drop;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean newValue) {
this.cancelled = newValue;
}
public ItemStack getDrop() {
return drop;
}
@@ -32,5 +18,4 @@ public class McMMOPlayerShakeEvent extends McMMOPlayerSkillEvent implements Canc
public void setDrop(ItemStack drop) {
this.drop = drop;
}
}

View File

@@ -54,7 +54,7 @@ public class BlockListener implements Listener {
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
List<Block> blocks = event.getBlocks();
BlockFace direction = event.getDirection();
@@ -84,7 +84,7 @@ public class BlockListener implements Listener {
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR)
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
if (event.isSticky()) {
// Needed only because under some circumstances Minecraft doesn't move the block
@@ -113,7 +113,7 @@ public class BlockListener implements Listener {
}
if (Repair.anvilMessagesEnabled && BlockUtils.isMcMMOAnvil(blockState)) {
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getTypeId());
UserManager.getPlayer(player).getRepairManager().placedAnvilCheck(blockState.getType());
}
}
@@ -149,26 +149,26 @@ public class BlockListener implements Listener {
/* Green Terra */
if (herbalismManager.canActivateAbility()) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
}
/*
* We don't check the block store here because herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler.
*/
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
if (SkillType.HERBALISM.getPermissions(player)) {
herbalismManager.herbalismBlockCheck(blockState);
}
}
/* MINING */
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
else if (BlockUtils.affectedBySuperBreaker(blockState) && ItemUtils.isPickaxe(heldItem) && SkillType.MINING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
MiningManager miningManager = mcMMOPlayer.getMiningManager();
miningManager.miningBlockCheck(blockState);
}
/* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.getPlaceStore().isTrue(blockState)) {
else if (BlockUtils.isLog(blockState) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
@@ -180,7 +180,7 @@ public class BlockListener implements Listener {
}
/* EXCAVATION */
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.getPlaceStore().isTrue(blockState)) {
else if (BlockUtils.affectedByGigaDrillBreaker(blockState) && ItemUtils.isShovel(heldItem) && SkillType.EXCAVATION.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
ExcavationManager excavationManager = mcMMOPlayer.getExcavationManager();
excavationManager.excavationBlockCheck(blockState);
@@ -221,6 +221,11 @@ public class BlockListener implements Listener {
blockState.update(true);
event.setCancelled(true);
}
else if (blockState.getType() == Material.FLOWER_POT) {
blockState.setType(Material.AIR);
blockState.update(true);
event.setCancelled(true);
}
}
}
else if (ItemUtils.isPickaxe(heldItem) && !heldItem.containsEnchantment(Enchantment.SILK_TOUCH)) {
@@ -275,19 +280,19 @@ public class BlockListener implements Listener {
}
if (mcMMOPlayer.getToolPreparationMode(ToolType.HOE) && ItemUtils.isHoe(heldItem) && (BlockUtils.affectedByGreenTerra(blockState) || BlockUtils.canMakeMossy(blockState)) && Permissions.greenTerra(player)) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.HERBALISM);
mcMMOPlayer.checkAbilityActivation(SkillType.HERBALISM);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.AXE) && ItemUtils.isAxe(heldItem) && BlockUtils.isLog(blockState) && Permissions.treeFeller(player)) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.WOODCUTTING);
mcMMOPlayer.checkAbilityActivation(SkillType.WOODCUTTING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.PICKAXE) && ItemUtils.isPickaxe(heldItem) && BlockUtils.affectedBySuperBreaker(blockState) && Permissions.superBreaker(player)) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.MINING);
mcMMOPlayer.checkAbilityActivation(SkillType.MINING);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.SHOVEL) && ItemUtils.isShovel(heldItem) && BlockUtils.affectedByGigaDrillBreaker(blockState) && Permissions.gigaDrillBreaker(player)) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.EXCAVATION);
mcMMOPlayer.checkAbilityActivation(SkillType.EXCAVATION);
}
else if (mcMMOPlayer.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockUtils.affectedByGigaDrillBreaker(blockState) || blockState.getType() == Material.SNOW || BlockUtils.affectedByBlockCracker(blockState) && Permissions.berserk(player))) {
SkillUtils.abilityCheck(mcMMOPlayer, SkillType.UNARMED);
mcMMOPlayer.checkAbilityActivation(SkillType.UNARMED);
}
}
@@ -334,17 +339,17 @@ public class BlockListener implements Listener {
}
}
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (SkillUtils.triggerCheck(player, block, AbilityType.BERSERK)) {
if (AbilityType.BERSERK.triggerCheck(player, block)) {
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && SkillUtils.triggerCheck(player, block, AbilityType.BLOCK_CRACKER)) {
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && AbilityType.BLOCK_CRACKER.triggerCheck(player, block)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
blockState.update();
}
}
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && SkillUtils.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && AbilityType.LEAF_BLOWER.triggerCheck(player, block)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}

View File

@@ -151,6 +151,10 @@ public class EntityListener implements Listener {
Entity attacker = event.getDamager();
if (Misc.isNPCEntity(attacker)) {
return;
}
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
}
@@ -455,6 +459,22 @@ public class EntityListener implements Listener {
}
}
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onEntityExplodeMonitor(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntsafeMetadataKey)) {
return;
}
event.blockList().clear();
}
/**
* Handle FoodLevelChange events that involve modifying the event.
*

View File

@@ -91,7 +91,7 @@ public class InventoryListener implements Listener {
Player player = Misc.getPlayerFromFurnace(furnaceBlock);
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.SMELTING)) {
if (Misc.isNPCEntity(player) || !SkillType.SMELTING.getPermissions(player)) {
return;
}

View File

@@ -49,6 +49,7 @@ import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
@@ -56,7 +57,6 @@ import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.SkillUtils;
public class PlayerListener implements Listener {
@@ -204,7 +204,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishHighest(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
return;
}
@@ -249,7 +249,7 @@ public class PlayerListener implements Listener {
public void onPlayerFishMonitor(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
if (Misc.isNPCEntity(player) || !SkillType.FISHING.getPermissions(player)) {
return;
}
@@ -362,7 +362,6 @@ public class PlayerListener implements Listener {
}
UserManager.addUser(player).actualizeRespawnATS();
ScoreboardManager.enablePowerLevelDisplay(player);
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
@@ -373,8 +372,8 @@ public class PlayerListener implements Listener {
}
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
player.sendMessage(LocaleLoader.getString("UpdateChecker.outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.newavailable"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
}
@@ -418,27 +417,27 @@ public class PlayerListener implements Listener {
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
int blockID = block.getTypeId();
Material type = block.getType();
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to repair an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
repairManager.handleRepair(heldItem);
player.updateInventory();
}
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
event.setCancelled(true);
// Make sure the player knows what he's doing when trying to salvage an enchanted item
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(blockID, true)) {
if (!(heldItem.getEnchantments().size() > 0) || repairManager.checkConfirmation(type, true)) {
repairManager.handleSalvage(block.getLocation(), heldItem);
player.updateInventory();
}
@@ -446,7 +445,7 @@ public class PlayerListener implements Listener {
}
/* BLAST MINING CHECK */
else if (miningManager.canDetonate()) {
if (block.getType() == Material.TNT) {
if (type == Material.TNT) {
event.setCancelled(true); // Don't detonate the TNT if they're too close
}
else {
@@ -457,26 +456,26 @@ public class PlayerListener implements Listener {
break;
case LEFT_CLICK_BLOCK:
blockID = block.getTypeId();
type = block.getType();
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
/* REPAIR CHECKS */
if (blockID == Repair.repairAnvilId && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
if (type == Repair.repairAnvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel repairing an enchanted item
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilId, 0);
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.repairAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Repair.Pretty.Name")));
}
}
/* SALVAGE CHECKS */
else if (blockID == Repair.salvageAnvilId && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
else if (type == Repair.salvageAnvilMaterial && Permissions.salvage(player) && Repair.isSalvageable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
// Cancel salvaging an enchanted item
if (repairManager.checkConfirmation(blockID, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilId, 0);
if (repairManager.checkConfirmation(type, false) && Config.getInstance().getRepairConfirmRequired()) {
mcMMOPlayer.setLastAnvilUse(Repair.salvageAnvilMaterial, 0);
player.sendMessage(LocaleLoader.getString("Skills.Cancelled", LocaleLoader.getString("Salvage.Pretty.Name")));
}
}
@@ -514,15 +513,15 @@ public class PlayerListener implements Listener {
if (BlockUtils.canActivateAbilities(blockState)) {
if (Config.getInstance().getAbilitiesEnabled()) {
if (BlockUtils.canActivateHerbalism(blockState)) {
SkillUtils.activationCheck(player, SkillType.HERBALISM);
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
}
SkillUtils.activationCheck(player, SkillType.AXES);
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
SkillUtils.activationCheck(player, SkillType.MINING);
SkillUtils.activationCheck(player, SkillType.SWORDS);
SkillUtils.activationCheck(player, SkillType.UNARMED);
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
}
ChimaeraWing.activationCheck(player);
@@ -534,14 +533,14 @@ public class PlayerListener implements Listener {
if (herbalismManager.canGreenThumbBlock(blockState)) {
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
if (herbalismManager.processGreenThumbBlocks(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
if (herbalismManager.processShroomThumb(blockState) && SkillUtils.blockBreakSimulate(block, player, false)) {
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
}
@@ -551,13 +550,13 @@ public class PlayerListener implements Listener {
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled()) {
SkillUtils.activationCheck(player, SkillType.AXES);
SkillUtils.activationCheck(player, SkillType.EXCAVATION);
SkillUtils.activationCheck(player, SkillType.HERBALISM);
SkillUtils.activationCheck(player, SkillType.MINING);
SkillUtils.activationCheck(player, SkillType.SWORDS);
SkillUtils.activationCheck(player, SkillType.UNARMED);
SkillUtils.activationCheck(player, SkillType.WOODCUTTING);
mcMMOPlayer.processAbilityActivation(SkillType.AXES);
mcMMOPlayer.processAbilityActivation(SkillType.EXCAVATION);
mcMMOPlayer.processAbilityActivation(SkillType.HERBALISM);
mcMMOPlayer.processAbilityActivation(SkillType.MINING);
mcMMOPlayer.processAbilityActivation(SkillType.SWORDS);
mcMMOPlayer.processAbilityActivation(SkillType.UNARMED);
mcMMOPlayer.processAbilityActivation(SkillType.WOODCUTTING);
}
/* ITEM CHECKS */
@@ -659,7 +658,7 @@ public class PlayerListener implements Listener {
// Do these ACTUALLY have to be lower case to work properly?
for (SkillType skill : SkillType.values()) {
String skillName = skill.toString().toLowerCase();
String localizedName = SkillUtils.getSkillName(skill).toLowerCase();
String localizedName = skill.getName().toLowerCase();
if (lowerCaseCommand.equals(localizedName)) {
event.setMessage(message.replace(command, skillName));

View File

@@ -0,0 +1,39 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerLevelUpEvent;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.events.skills.abilities.McMMOPlayerAbilityActivateEvent;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
public class ScoreboardsListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
ScoreboardManager.setupPlayer(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
ScoreboardManager.teardownPlayer(event.getPlayer());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerLevelUp(McMMOPlayerLevelUpEvent event) {
ScoreboardManager.handleLevelUp(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerXp(McMMOPlayerXpGainEvent event) {
ScoreboardManager.handleXp(event.getPlayer(), event.getSkill());
}
@EventHandler(priority = EventPriority.MONITOR)
public void onAbility(McMMOPlayerAbilityActivateEvent event) {
ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill());
}
}

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