1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2026-02-19 10:22:58 +01:00

Compare commits

..

378 Commits

Author SHA1 Message Date
bm01
dc48d467f5 Return to HashMap! 2012-06-24 22:46:45 +02:00
nossr50
0b0390620e Whoops :D 2012-06-24 13:26:49 -07:00
nossr50
24eb34c182 Back to the old way of doing things 2012-06-24 13:26:21 -07:00
nossr50
1a5bd1b6a2 Getting ready for release 2012-06-24 12:59:54 -07:00
nossr50
ab7b6ce460 Fixed bug that caused NPE when trying to compare null parties 2012-06-24 12:48:03 -07:00
GJ
c4cd677021 Added new methods to replace deprecation in latest Bukkit. Commented out
until RB.
2012-06-23 12:13:51 -04:00
bm01
6b84d39dda Fixed AE abilities not being applied correctly 2012-06-22 23:10:17 +02:00
bm01
e61342177d Simplified combat ability checks 2012-06-22 20:20:28 +02:00
bm01
d51fa92b46 Made 'shooterless' arrows dodgeable 2012-06-22 19:39:14 +02:00
bm01
3e20dc7de6 combatChecks optimization 2012-06-22 18:54:49 +02:00
GJ
dce1d7ba39 Fixed calculations on Reduced Cooldown perk 2012-06-22 10:57:51 -04:00
GJ
adffea1d52 Increased the seconds for activation time perk. 2012-06-22 10:13:37 -04:00
GJ
20b73dcc84 Fixed not checking if an Entity was a LivingEntity before applying the
Counter-Attack ability.
2012-06-22 09:47:18 -04:00
GJ
b331fa353b Added increased activate time donor perks 2012-06-21 23:01:02 -04:00
GJ
9fe14609af Locale update. 2012-06-21 22:26:29 -04:00
GJ
f6973b8907 Changelog update. 2012-06-21 21:51:43 -04:00
GJ
8738036f6f Added Reduced Cooldown perk for donors. 2012-06-21 21:50:48 -04:00
GJ
fce02dc0e5 Fixed possible NPE with Acrobatics fall checks. 2012-06-21 21:04:19 -04:00
GJ
2bef0e833f Rework of Swords handling 2012-06-21 09:04:45 -04:00
GJ
9040a2a2e3 Optimizations to Combat.java 2012-06-18 08:50:14 -04:00
NuclearW
4407ed0a6f Fixed bug with Chunklets not being reloaded on /reload 2012-06-16 21:43:04 -04:00
GJ
09721518b0 Fixed Unarmed using Taming levels.
My copy-paste skills are failing.
2012-06-15 11:11:57 -04:00
GJ
8ad6337dde Avoid calling the same thing 3 times. 2012-06-15 10:58:38 -04:00
bm01
271740d2ac Re-added mcMMO.getPlayerProfile(Player) 2012-06-15 10:03:00 +02:00
GJ
48dd537257 More reworking of Unarmed, renamed ArcheryBonusDamageEventHandler for
clarity's sake.
2012-06-14 23:59:36 -04:00
GJ
77b4aaa50d Updating Unarmed (WIP) 2012-06-14 23:59:35 -04:00
bm01
1014316581 Whoops D: 2012-06-15 03:32:46 +02:00
bm01
739cd83155 Forgot to cancel the task 2012-06-15 03:30:36 +02:00
bm01
df08bc4da0 Changelog update 2012-06-15 02:56:36 +02:00
bm01
55e832d4f6 Do not track arrow if the bow has Infinity 2012-06-15 02:53:11 +02:00
bm01
032472dcb3 Avoid unnecessary iteration 2012-06-15 02:46:41 +02:00
bm01
68bf93d1ac Remove inactive entities from the arrow tracker 2012-06-15 02:43:13 +02:00
bm01
ba133f94fc Extra equals 2012-06-15 02:34:24 +02:00
bm01
064c16f4d7 Reverted last commit 2012-06-15 02:14:53 +02:00
bm01
5a394ee744 Fixed killed entities not being removed from arrowTracker 2012-06-15 02:08:15 +02:00
bm01
3bc2f5dc55 Fixed Archery using Taming skill level 2012-06-15 02:06:06 +02:00
GJ
6f63818e5f Check for the block before throwing the fake break event. 2012-06-14 10:24:58 -04:00
GJ
a5d7bee939 Spacing 2012-06-14 00:01:31 -04:00
bm01
9d396162f1 Hardcore.java cleanup 2012-06-14 01:22:35 +02:00
bm01
4a0d9a96ab Fixed minor bug with Vampirism notification 2012-06-14 00:48:40 +02:00
GJ
9f65e5a9ab PermissionsHandler was a stupid idea. 2012-06-13 12:31:20 -04:00
GJ
c71f4e438b Organize imports. 2012-06-13 08:54:02 -04:00
GJ
14d13eb4c7 Archery rework. 2012-06-13 08:53:18 -04:00
GJ
29c629eb22 WIP on Archery rework. 2012-06-12 21:36:17 -04:00
bm01
050b794b42 Fixed NPE with /mmoedit 2012-06-12 23:31:32 +02:00
NuclearW
89b5f8c275 Changelog 2012-06-12 17:01:18 -04:00
NuclearW
f589197321 Load the lowest chunklets right now.
Thanks for @Glitchfinder for finding this glitch.

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

I'm fairly sure that the xpHandler should be in Repair, but that's private at the moment so usage from the Manager is impossible except with public modifier, which is unacceptable.

Considering moving Repair to the new repair package, perhaps eventually all skills will have packages and skills.  Moving it seems like the logical solution with protected modifier.
2012-05-17 04:32:14 -04:00
NuclearW
2a46a5c00a Remove boost from the repair xpHandler
Replace old false values with doubles which will produce identical results

While the boost value will remain confusing in configs later, it will now at least be easier.
2012-05-17 04:28:31 -04:00
NuclearW
d3b7af3c5f Beginnings of the repairable 2012-05-17 04:01:47 -04:00
NuclearW
db59f24873 Cleanup 2012-05-17 03:57:16 -04:00
GJ
5645bf7982 Mod support - XP gain & double drops should now work for custom blocks
EXCEPT Woodcutting. Custom excavation blocks will also never drop
treasures.
2012-05-17 00:24:33 -04:00
GJ
6cbf87b52c Fixed custom tools & armor not being repairable. 2012-05-16 15:48:52 -04:00
GJ
bc642deebd Custom armor can now be repaired. 2012-05-15 16:12:59 -04:00
GJ
e84a9643f8 Enchanted custom tools should now support Arcane Forging. 2012-05-15 14:39:39 -04:00
GJ
e9af0ebdc5 Custom tools - modify XP gain from breaking blocks on a per tool basis. 2012-05-15 14:21:21 -04:00
GJ
29ee8a035b Custom tools - should now support enabling/disabling ability activation
per tool.
2012-05-15 13:44:39 -04:00
GJ
81ac4e8d01 WIP on custom mod support - should now be able to repair custom tools at
an anvil.
2012-05-15 10:44:57 -04:00
NuclearW
ecc68d373f Typo fix in Acrobatics guide 2012-05-15 04:06:05 -04:00
NuclearW
3032572f18 New factories means more jobs for a better economy 2012-05-15 01:43:34 -04:00
NuclearW
bcee6abb65 Re-add call to updateInventory 2012-05-15 00:49:19 -04:00
nossr50
7e0b8ddf50 HudType will default to 'STANDARD' for MySQL DB - only good for new users 2012-05-14 15:13:55 -07:00
NuclearW
91dcb508b3 POOT DONATION HERE 2012-05-14 17:52:07 -04:00
GJ
d549e2722d Removed unused import. 2012-05-14 10:48:46 -04:00
nossr50
3bb29c8308 mcMMO's motd now links to the new website rather than the wiki 2012-05-13 19:00:49 -07:00
nossr50
0121228d88 Update README.creole 2012-05-13 15:30:09 -07:00
bm01
cbafa7110a Fixed minor Green Terra bugs on Stone Brick 2012-05-10 15:54:29 +02:00
bm01
06791beabd Fixed double Config instantiation causing NPE on PlayerProfile.save() 2012-05-09 15:58:11 +02:00
bm01
68b9857409 Fixed /<skill> command being processed twice when an alias was used 2012-05-09 13:06:40 +02:00
bm01
112a0df8c2 Minor locale fix 2012-05-09 12:10:59 +02:00
bm01
73717278ff Fixed /party not showing properly the member list 2012-05-09 11:38:22 +02:00
bm01
5fa79926db Fixed arrow boucing off entities on daze proc 2012-05-08 21:58:01 +02:00
bm01
06f97ac2f1 Fixed a bug where a player could gain Acrobatics exp while riding a cart 2012-05-08 20:20:23 +02:00
bm01
c2b4961b8d Removed exp gain when an arrow strikes its shooter 2012-05-08 20:12:41 +02:00
bm01
9b3838b912 Improved attacker and defender's party check 2012-05-08 19:42:26 +02:00
bm01
946ea19371 Fixed bad /party fix :( 2012-05-08 06:58:50 +02:00
NuclearW
419e011d0b Changelog for last commit 2012-05-07 22:50:24 -04:00
NuclearW
b0157c9bd2 Replace Bukkit Metadata for user placed blocks 2012-05-07 22:38:22 -04:00
nossr50
37d146e8fa Fixed various NPE errors when loading up mcMMO 2012-05-06 14:51:25 -07:00
bm01
063d982750 Fixed the fix! 2012-05-06 11:05:51 +02:00
bm01
fbfeaa0f95 Fixed /party not working properly with 2 arguments 2012-05-06 11:02:08 +02:00
bm01
9b11b02658 Minor locale fix 2012-05-06 09:55:15 +02:00
bm01
3e435c419a Refixed NPE due to GainXp task 2012-05-06 09:47:25 +02:00
GJ
1b37ba8daa Fixed a few issues from the merge, added the mod directory to the zip
backup.
2012-05-05 13:51:54 -04:00
nossr50
b529219a0e Merge branch 'master' of github.com:mcMMO-Dev/mcMMO
Conflicts:
	src/main/java/com/gmail/nossr50/mcMMO.java
2012-05-05 10:20:26 -07:00
nossr50
d9b3eff18f Changed how a few variables were initialized 2012-05-05 10:16:41 -07:00
GJ
cb5ada6ec9 Fix for config files not being created at startup. 2012-05-05 13:02:55 -04:00
bm01
baf7ffd441 Fixed french locale string causing IAE on repair skillup 2012-05-04 20:17:17 +02:00
GJ
2b4ca80a95 Start of work on allowing custom tool/block mods. This version should
allow for XP gain from vanilla blocks with custom tools. Please report
any issues to facilitate further development.
2012-05-04 14:04:42 -04:00
bm01
b5963936fd Fixed /ability not checking the right permission 2012-05-04 19:42:00 +02:00
bm01
354ed9ede0 Fixed NPE on /party 2012-05-04 11:04:05 +02:00
bm01
7ad9b8ff3e Changed Arrow Retrieval to drop arrows individually 2012-05-04 10:27:49 +02:00
bm01
6dc522a044 Fixed Arrow Retrieval dropping only one arrow 2012-05-03 16:45:30 +02:00
GJ
3e91bc8c1e Can now enable/disable specific skills for PVP & PVE 2012-05-03 10:39:32 -04:00
nossr50
3218c544dc Added level curve modifier 2012-05-02 06:10:32 -07:00
GJ
1ae11da036 Start of work on allowing Combat skills to be enabled for just PVP or
PVE
2012-05-01 22:42:45 -04:00
bm01
84e36d758e Fixed /p and /a incompatibilities with bChatManager 2012-05-02 00:55:43 +02:00
bm01
06ede80435 Fixed Iron Grip working reversely 2012-05-01 23:51:49 +02:00
bm01
dbc57060ee Reduced bleeding ticks damage 2012-05-01 23:49:11 +02:00
GJ
798bd46d0a Command updates - Repair (Finally done!) 2012-05-01 16:29:52 -04:00
GJ
c95f388d8d Allow for checking if ALL double drops are disabled via config. 2012-05-01 15:56:09 -04:00
GJ
a9024ebc6b Fixed bug with getting NO logs from Tree Feller if double drops were
disabled in the config file.
2012-05-01 15:25:28 -04:00
GJ
33bc2d8a6b Command updates - Woodcutting & Unarmed 2012-05-01 15:15:30 -04:00
GJ
cc60f2f308 Command update - Swords 2012-05-01 14:28:20 -04:00
GJ
edaa51593b Skills refactoring 2012-05-01 13:58:47 -04:00
GJ
e2265dd6f7 Updates to repair command, minor permission node & config updates 2012-05-01 13:53:00 -04:00
nossr50
e1cf89c3bf Vamprirism updates. 2012-05-01 09:04:29 -07:00
nossr50
8cd1541893 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2012-05-01 08:48:10 -07:00
nossr50
9d510815b4 Vampirism for hardcore mode, needs testing. 2012-05-01 08:47:57 -07:00
GJ
44d22d93da Command update - Mining. Also fixed typo on new Herbalism permission. 2012-05-01 10:39:50 -04:00
nossr50
f7405a82e6 Fixed NPE when user clicks the HUD button for Spout 2012-05-01 06:30:57 -07:00
GJ
04f3e44c3a Command updates - Herbalism 2012-05-01 09:11:56 -04:00
GJ
6cc207a10c Fixed bug with Chimera Wing failing when used on half-blocks - Fixes
MCCORE-221

Also added treasures.yml to the zip backup.
2012-05-01 08:28:54 -04:00
GJ
6b5e615a23 Tabs are bad and we should feel bad for having them. 2012-05-01 07:54:37 -04:00
Grant
46268a7cf3 Merge pull request #202 from shatteredbeam/master
Zip automation running in SQL mode Fix
2012-05-01 04:41:09 -07:00
bm01
3682fbf531 Reverted last commit 2012-05-01 10:51:17 +02:00
bm01
0928b54d90 Actually fixed Hardcore 2012-05-01 10:49:36 +02:00
bm01
5a10339adc Fixed Hardcore mode always enabled 2012-05-01 10:43:04 +02:00
Shatteredbeam
7c412cbec8 Fix for zip backup running in SQL mode. 2012-05-01 00:07:17 -07:00
bm01
d235ca8ed8 Fixed SQLReconnect not working 2012-05-01 07:53:03 +02:00
GJ
97511be64a One more tweak. 2012-05-01 01:43:00 -04:00
GJ
3bd5aaa251 Importing by * is a bad idea. 2012-05-01 01:40:47 -04:00
GJ
ae2d9d8387 Locale update. 2012-05-01 01:33:42 -04:00
GJ
33c9694d26 Changelog update & the removal of a useless p 2012-05-01 01:25:13 -04:00
GJ
dbede7f81a Added config options for specific double drops. Implements MCCORE-226 2012-05-01 01:14:32 -04:00
bm01
c8ad2bb454 Added bm01 to authors :3 2012-05-01 01:34:21 +02:00
bm01
18c52a5e23 Cleanup 2012-05-01 01:32:50 +02:00
bm01
ca1954ff80 Merge pull request #201 from shatteredbeam/master
Zip Handling PR -
2012-04-30 16:08:13 -07:00
shatteredbeam
5a3574734c Added automatic backup of datafiles. 2012-04-30 15:48:59 -07:00
nossr50
5c6d10b2db Mining now completely ignore Silk Touch enchanted picks 2012-04-30 09:30:07 -07:00
nossr50
7e96ced4c4 Shortened the hardcore mode message 2012-04-30 07:19:13 -07:00
nossr50
8da259cabc Updated perm node behaviour and changelog 2012-04-30 07:17:10 -07:00
nossr50
f978d739bb Updates 2012-04-30 07:11:03 -07:00
nossr50
7b2d50e93e *Actually* fixing the Maths 2012-04-30 07:05:11 -07:00
nossr50
8bec50663f Fixing some Maths 2012-04-30 07:01:00 -07:00
nossr50
f4f5063efe Always forgot to update the changelog 2012-04-30 06:45:56 -07:00
nossr50
11782ac34d Bah, don't know why this got deleted. 2012-04-30 06:44:56 -07:00
nossr50
bfec3fff36 Forgot to register events for the new listener 2012-04-30 06:43:12 -07:00
nossr50
d8c0a56577 Added basic hardcore mode functionality, needs testing. 2012-04-30 06:41:58 -07:00
nossr50
ff1326a44f Revert "Added basic functionality of Hardcore Mode, needs testing..."
This reverts commit 1fa4fccbcc.
2012-04-30 06:41:09 -07:00
nossr50
1fa4fccbcc Added basic functionality of Hardcore Mode, needs testing... 2012-04-30 06:39:30 -07:00
nossr50
323b41fd58 Adding in config nodes for Hardcore Mode (WIP) 2012-04-30 06:21:14 -07:00
GJ
3d2b881b0e Command cleanup - Fishing. Added 2 new fishing permissions nodes. 2012-04-30 08:26:37 -04:00
GJ
def41af469 Command update - Excavation 2012-04-30 07:51:02 -04:00
GJ
4750aba763 Added permissions node for Greater Impact, cleanup of Axes command 2012-04-30 07:46:08 -04:00
GJ
5a9249dee1 Locale file update. 2012-04-29 23:05:57 -04:00
GJ
064fc0a8e2 Command format & permission changes, other minor cleanup. 2012-04-29 22:58:54 -04:00
bm01
67de70432c Fixed /party displaying twice the leader 2012-04-30 03:10:33 +02:00
bm01
facd71bd71 Minor locale things 2012-04-30 03:09:05 +02:00
nossr50
96e6270520 Changed MySQL to not save everything at once 2012-04-29 12:02:24 -07:00
nossr50
51c45e86ce Fixing formatting 2012-04-29 08:11:03 -07:00
189 changed files with 13373 additions and 6225 deletions

View File

@@ -7,6 +7,108 @@ Key:
! Change
- Removal
Version 1.3.09
+ Added compatibility with AntiCheat (Which I highly recommend to prevent cheating)
+ Added several permission nodes to give individual users special perks (Double/Triple/Quadruple XP)
+ Added reduced cooldown permission nodes as special perks (1/4, 1/3, 1/2 cooldown)
+ Added increased activation time permissions nodes as special perks (+4, +8, and +12 seconds)
+ Added API for plugins to add custom tools directly via Spout - repair / abilities do not work ATM
+ Added offline party members to the list displayed by /party
+ Added possibility to kick offline members from parties
= Fixed bug that would cause a NPE for players that had no parties
= Fixed Vampirism not notifying the correct amount of stolen levels
= Fixed bug with Acrobatics not saving you from deadly falls
= Fixed /mcremove being applied only after a reload
= Fixed Archery PVE disablement not working properly
= Fixed possible NPE when a projectile is shot by a dispenser or doesn't have any shooter
= Fixed issue with NoCheatPlus and Serrated Strikes / Skull Splitter (fight.noswing)
= Fixed tiny memory leak concerning Archery
= Fixed bug where you could receive Archery XP from Potions
= Fixed bug where Chunklets for the < 64 y coordinates would not be properly loaded
= Fixed exploit with block duplication via piston pushing
= Fixed bug with falling sand/gravel not being tracked
= Fixed bug with Tree Feller not working with custom axes
= Fixed bug with locale strings when trying to teleport to a non-existent player
= Fixed bug with Tree Feller changing durability before checking for axe splintering
= Fixed bug with Repair Mastery permission due to typo
= Fixed bug with repairing items that use metadata
= Fixed bug with Chunklets not being reloaded on /reload
= Fixed possible NPE when falling with no item in hand
! API methods can now only be used in a static way
! Arrows shot from a bow having the Infinity enchantment can no longer be retrieved
! Arrows that aren't shot by an entity are now able to be dodged (currently only from dispensers)
! Changed Spout settings to be in their own config file (spout.yml)
! Changed file format for parties (parties.yml), previous files are no longer used
! Changed mcMMO to inform on corrupt Chunklets and make new ones
Version 1.3.08
+ Added more notifications about Vampirism and Hardcore mode on player death
+ Added information about Hardcore mode when joining a server running Hardcore mode
+ Added new hidden.yml inside the jar for very sensitive config options for advanced users
+ Added option to disable Chunklets for servers which do not have doubledrops and do not care about xp farming
+ Added new "Max_Seconds" setting in config.yml to limit the max time of abilities
+ Added new repair configs to allow customization of the repair skill
+ Added message to inform users about hardcore mode on login
= Fixed exploit where you could gain tons of Acrobatics XP from spamming Ender Pearls
= Fixed normal pistons marking a block as user-placed on retract if it wasn't a sticky piston (thanks turt2live!)
= Fixed handling of the Unbreaking enchantment so that tools are actually damaged as they should now
= Fixed hurting pet cats with serrated strikes
! Changed Hardcore Vampirism to require the victim to have at least half the skill level of the killer in order for vampirism to proc (this is to avoid exploitation)
! Changed Hardcore Vampirism to steal a minimum of 1 skill level from a player no matter the percentage
! Changed Hardcore & Vampirism to not be executed if percentages were set to zero or below
! Changed Vampirism to actually remove stats from the victim
! Changed Vampirism to inform the victim of their stat loss
! Changed Mining to allow Silk Touch to work again since the dupe exploit has been fixed.
! Changed Metrics to also report if the server uses plugin profiling
- Removed level and item settings from Repair skill in config.yml
Version 1.3.07
+ Added ability to gain XP from custom blocks. Enable custom blocks in the config file, then enter the data in the blocks.yml file.
+ Added ability to gain XP with custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
+ Added ability to repair custom tools. Enable custom tools in the config file, then enter the data in the tools.yml file.
+ Added ability to repair custom armor. Enable custom armor in the config file, then enter the data in the armor.yml file.
+ Added functionality which makes a new folder in all world files "mcmmo_data" to store player placed block information in
+ Added new configurable Hardcore mode functionality to mcMMO
+ Added new configurable Vampirism PVP stat leech for Hardcore mode
+ Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode'
+ Added configurable level curve multiplier which allows for tweaking the steepness of the XP needed to level formula
+ Added a permission node for Archery bonus damage
+ Added a permission node for Greater Impact ability
+ Added permission nodes for Treasure & Magic Hunter for Fishing
+ Added a permission node for Farmer's Diet
+ Added config options for enabling/disabling specific double drops
+ Added automatic zip backup of flatfile database & config files
+ Added config options to enable/disable specific skills for PVP & PVE
= Fixed bug where Tree Feller was looking at the wrong blocks for determining how much to take down.
= Fixed bug where Green Terra consumed seeds even on Mossy Stone Brick
= Fixed bug where the client didn't reflect the Stone Brick to Mossy Stone Brick change
= Fixed bug where an arrow could bounce off entities on daze proc
= Fixed bug where a player could gain Acrobatics experience while riding a cart
= Fixed /party not working properly with 2 arguments
= Fixed /party not showing properly the member list
= Fixed /ability not checking the right permission
= Fixed rare NPE on /party command
= Fixed Arrow Retrieval dropping only one arrow
= Fixed /p and /a incompatibilities with bChatManager
= Fixed Iron Grip working reversely
= Fixed NPE when user clicked the HUD button with Spout
= Fixed bug where the permission node for Impact didn't work
= Fixed some bypass nodes defaulting true for Ops
= Fixed bug with trying to use Chimera Wing while standing on a half-block
= Fixed duplication bug when a placed block was mined after a server restart
= Fixed exploit where shooting yourself with an arrow gave Archery XP
! Changed the mcMMO motd to link to the new website rather than the wiki
! Changed bleeding ticks damage to 1 from 2
! Changed Mining to ignore blocks when the pick is enchanted with Silk Touch
! Changed Super Breaker to be non-functional when used with a Silk Touch enchanted pick
! Changed MySQL to save player information 50ms apart from each other to reduce the load on the MySQL server
! Changed the permission node for Blast Mining detonation to mcmmo.ability.blastmining.detonate (was mcmmo.skills.blastmining) for the sake of consistency
! Changed skill commands to only display what you have permissions for
! Changed mcMMO to use a new storage system for player placed blocks
- Removed some unused permission nodes
- Removed a few config options in favor of permissions nodes (Hunger Bonus, Armor/Tool Repair, Instant Wheat Regrowth)
- Removed level requirement for repairing string tools from the config file
Version 1.3.06
+ Added Iron Golem XP for aggressive golems
+ Added permissions check to skill functions
@@ -31,7 +133,7 @@ Version 1.3.06
! Changed Bleeding to now stack to a finite number on Monsters and will wear off eventually
! Changed how we handled the config file to prevent any bugs when returning values
! Changed locale files to use a new naming scheme. This breaks ALL old locale files. If you want to assist with re-translating anything, go to getlocalization.com/mcMMO
! Changed mcremove to check for users in the MySQL DB before sending queries to remove them
! Changed /mcremove to check for users in the MySQL DB before sending queries to remove them
! Changed how the tree feller threshold worked for the better
! Changed /mcremove to no longer kick players when they are removed from database
! Changed /mcremove to work on offline users for FlatFile

View File

@@ -1,6 +1,9 @@
== mcMMO
**The RPG lovers mod**
=== Forums
http://forums.mcmmo.info Talk with developers and the community about mcMMO here
=== Brief Description
mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience.

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

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

View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.3.06</version>
<version>1.3.09</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>

View File

@@ -9,7 +9,10 @@ import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ChatAPI {
public final class ChatAPI {
private ChatAPI() {}
/**
* Send a message to all members of a party
* </br>
@@ -19,7 +22,7 @@ public class ChatAPI {
* @param party The name of the party to send to
* @param message The message to send
*/
public void sendPartyChat(String sender, String party, String message) {
public static void sendPartyChat(String sender, String party, String message) {
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(sender, party, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);
@@ -33,7 +36,7 @@ public class ChatAPI {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
if (Users.getProfile(player).inParty()) {
if (Users.getProfile(player).getParty().equalsIgnoreCase(chatEvent.getParty())) {
if (Users.getProfile(player).getParty().getName().equalsIgnoreCase(chatEvent.getParty())) {
player.sendMessage(pPrefix + chatEvent.getMessage());
}
}
@@ -48,7 +51,7 @@ public class ChatAPI {
* @param sender The name of the sender to display in the chat
* @param message The message to send
*/
public void sendAdminChat(String sender, String message) {
public static void sendAdminChat(String sender, String message) {
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(sender, message);
mcMMO.p.getServer().getPluginManager().callEvent(chatEvent);

View File

@@ -3,10 +3,12 @@ package com.gmail.nossr50.api;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class ExperienceAPI {
public final class ExperienceAPI {
private ExperienceAPI() {}
/**
* Check the XP of a player. This should be called after giving XP to process level-ups.
@@ -14,12 +16,12 @@ public class ExperienceAPI {
* @param player The player to check
* @param skillType The skill to check
*/
private void checkXP(Player player, SkillType skillType) {
private static void checkXP(Player player, SkillType skillType) {
if (skillType.equals(SkillType.ALL)) {
Skills.XpCheckAll(player);
Skills.xpCheckAll(player, Users.getProfile(player));
}
else {
Skills.XpCheckSkill(skillType, player);
Skills.xpCheckSkill(skillType, player, Users.getProfile(player));
}
}
@@ -32,7 +34,7 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addRawXP(Player player, SkillType skillType, int XP) {
public static void addRawXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverride(skillType, XP);
checkXP(player, skillType);
}
@@ -46,7 +48,7 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addMultipliedXP(Player player, SkillType skillType, int XP) {
public static void addMultipliedXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXPOverrideBonus(skillType, XP);
checkXP(player, skillType);
}
@@ -60,7 +62,7 @@ public class ExperienceAPI {
* @param skillType The skill to add XP to
* @param XP The amount of XP to add
*/
public void addXP(Player player, SkillType skillType, int XP) {
public static void addXP(Player player, SkillType skillType, int XP) {
Users.getProfile(player).addXP(skillType, XP);
checkXP(player, skillType);
}
@@ -74,7 +76,7 @@ public class ExperienceAPI {
* @param skillType The skill to get XP for
* @return the amount of XP in a given skill
*/
public int getXP(Player player, SkillType skillType) {
public static int getXP(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillXpLevel(skillType);
}
@@ -87,7 +89,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the XP amount for
* @return the amount of XP left before leveling up a specifc skill
*/
public int getXPToNextLevel(Player player, SkillType skillType) {
public static int getXPToNextLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getXpToLevel(skillType);
}
@@ -101,7 +103,7 @@ public class ExperienceAPI {
* @param levels Number of levels to add
* @param notify True if this should fire a level up notification, false otherwise.
*/
public void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
public static void addLevel(Player player, SkillType skillType, int levels, boolean notify) {
Users.getProfile(player).addLevels(skillType, levels);
if (notify) {
@@ -118,7 +120,7 @@ public class ExperienceAPI {
* @param skillType The skill to get the level for
* @return the level of a given skill
*/
public int getLevel(Player player, SkillType skillType) {
public static int getLevel(Player player, SkillType skillType) {
return Users.getProfile(player).getSkillLevel(skillType);
}
@@ -130,7 +132,7 @@ public class ExperienceAPI {
* @param player The player to get the power level for
* @return the power level of the player
*/
public int getPowerLevel(Player player) {
public static int getPowerLevel(Player player) {
return Users.getProfile(player).getPowerLevel();
}
}

View File

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

View File

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

View File

@@ -6,8 +6,8 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class CommandHelper {

View File

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

View File

@@ -12,8 +12,8 @@ import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class AddlevelsCommand implements CommandExecutor{

View File

@@ -8,10 +8,11 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
//TODO: Any way we can make this work for offline use?
@@ -47,7 +48,8 @@ public class AddxpCommand implements CommandExecutor {
xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
PlayerProfile profile = Users.getProfile(modifiedPlayer);
profile.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -59,10 +61,10 @@ public class AddxpCommand implements CommandExecutor {
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {
@@ -78,8 +80,9 @@ public class AddxpCommand implements CommandExecutor {
case 3:
modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName();
PlayerProfile profile = Users.getProfile(modifiedPlayer);
if (!Users.getProfile(modifiedPlayer).isLoaded()) {
if (!profile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
@@ -94,7 +97,7 @@ public class AddxpCommand implements CommandExecutor {
skill = Skills.getSkillType(args[1]);
String message;
Users.getProfile(modifiedPlayer).addXPOverride(skill, xp);
profile.addXPOverride(skill, xp);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -109,10 +112,10 @@ public class AddxpCommand implements CommandExecutor {
modifiedPlayer.sendMessage(ChatColor.GREEN + "You were awarded " + xp + " experience in " + skillName + "!"); //TODO: Needs more locale.
if (skill.equals(SkillType.ALL)) {
Skills.XpCheckAll(modifiedPlayer);
Skills.xpCheckAll(modifiedPlayer, profile);
}
else {
Skills.XpCheckSkill(skill, modifiedPlayer);
Skills.xpCheckSkill(skill, modifiedPlayer, profile);
}
}
else {

View File

@@ -7,26 +7,19 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class MmoeditCommand implements CommandExecutor {
private final mcMMO plugin;
public MmoeditCommand (mcMMO plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer modifiedPlayer;
PlayerProfile PP;
PlayerProfile playerProfile;
int newValue;
SkillType skill;
String skillName;
@@ -48,7 +41,7 @@ public class MmoeditCommand implements CommandExecutor {
modifiedPlayer = (Player) sender;
newValue = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]);
PP = Users.getProfile(modifiedPlayer);
playerProfile = Users.getProfile(modifiedPlayer);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
@@ -57,7 +50,7 @@ public class MmoeditCommand implements CommandExecutor {
skillName = Misc.getCapitalized(skill.toString());
}
PP.modifySkill(skill, newValue);
playerProfile.modifySkill(skill, newValue);
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
}
else {
@@ -71,46 +64,47 @@ public class MmoeditCommand implements CommandExecutor {
return true;
case 3:
modifiedPlayer = plugin.getServer().getOfflinePlayer(args[0]);
String playerName = modifiedPlayer.getName();
PP = Users.getProfile(modifiedPlayer);
if (!PP.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
if (!Misc.isInt(args[2])) {
sender.sendMessage(usage);
return true;
}
if (!Skills.isSkill(args[1])) {
skill = Skills.getSkillType(args[1]);
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
return true;
}
if (Misc.isInt(args[2])) {
newValue = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]);
String message;
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
}
else {
skillName = Misc.getCapitalized(skill.toString());
}
Users.getProfile(modifiedPlayer).modifySkill(skill, newValue);
newValue = Integer.valueOf(args[2]);
playerProfile = Users.getProfile(args[0]);
if (skill.equals(SkillType.ALL)) {
skillName = "all skills";
message = ChatColor.RED + "All skills have been modified for " + playerName + "."; //TODO: Use locale
}
else {
skillName = Misc.getCapitalized(skill.toString());
message = ChatColor.RED + skillName + " has been modified for " + playerName + "."; //TODO: Use locale
}
if (playerProfile != null) {
Player player = playerProfile.getPlayer();
sender.sendMessage(message);
if (modifiedPlayer.isOnline()) {
((Player) modifiedPlayer).sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
if (player.isOnline()) {
player.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
}
}
else {
sender.sendMessage(usage);
playerProfile = new PlayerProfile(null, args[0], false);
if (!playerProfile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return true;
}
}
sender.sendMessage(ChatColor.RED + skillName + " has been modified for " + args[0] + "."); //TODO: Use locale
playerProfile.modifySkill(skill, newValue);
playerProfile.save();
return true;
default:

View File

@@ -18,7 +18,7 @@ public class McabilityCommand implements CommandExecutor {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ability")) {
return true;
}

View File

@@ -42,7 +42,7 @@ public class MccCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Commands.Other"));
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
player.sendMessage("/mctop " + LocaleLoader.getString("m.mccLeaderboards"));
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.getInstance().mcAbility(player)) {
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));

View File

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

View File

@@ -61,7 +61,7 @@ public class McrefreshCommand implements CommandExecutor {
return true;
}
PP.setRecentlyHurt((long) 0);
PP.setRecentlyHurt(0);
PP.resetCooldowns();
PP.resetToolPrepMode();
PP.resetAbilityMode();

View File

@@ -5,6 +5,7 @@ import java.io.FileReader;
import java.io.FileWriter;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -13,15 +14,17 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McremoveCommand implements CommandExecutor {
private final String location = mcMMO.usersFile;
private final String location;
private final mcMMO plugin;
public McremoveCommand (mcMMO plugin) {
this.plugin = plugin;
this.location = mcMMO.usersFile;
}
@Override
@@ -39,7 +42,7 @@ public class McremoveCommand implements CommandExecutor {
switch (args.length) {
case 1:
playerName = args[0];
success = ChatColor.GREEN + playerName + "was successfully removed from the database!"; //TODO: Locale
success = ChatColor.GREEN + playerName + " was successfully removed from the database!"; //TODO: Locale
break;
default:
@@ -95,11 +98,15 @@ public class McremoveCommand implements CommandExecutor {
}
//Force PlayerProfile stuff to update
Player player = plugin.getServer().getPlayer(playerName);
OfflinePlayer player = plugin.getServer().getOfflinePlayer(playerName);
PlayerProfile playerProfile = Users.getProfile(player);
if (player != null && Users.players.containsKey(playerName.toLowerCase())) {
Users.removeUser(player);
Users.addUser(player);
if (playerProfile != null) {
Users.getProfiles().remove(playerProfile);
if (player.isOnline()) {
Users.addUser((Player) player);
}
}
return true;

View File

@@ -7,19 +7,20 @@ import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
public class MctopCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
if (!Config.getInstance().getUseMySQL()) {
switch (args.length) {

View File

@@ -63,15 +63,23 @@ public class ACommand implements CommandExecutor {
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
if (PP.getAdminChatMode()) {
player.chat(message);
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.toggleAdminChat();
player.chat(message);
PP.toggleAdminChat();
message = chatEvent.getMessage();
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + player.getName() + ChatColor.AQUA + "} ";
plugin.getLogger().info("[A]<" + player.getName() + "> " + message);
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
p.sendMessage(prefix + message);
}
}
}
else {

View File

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

View File

@@ -11,6 +11,7 @@ import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
//TODO: Make this work from console.
@@ -36,11 +37,9 @@ public class InviteCommand implements CommandExecutor {
switch (args.length) {
case 1:
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
if (!PP.inParty()) {
if (!playerProfile.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@@ -48,13 +47,12 @@ public class InviteCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[0]);
if (target != null) {
if (partyInstance.canInvite(player, PP)) {
PlayerProfile PPt = Users.getProfile(target);
PPt.modifyInvite(PP.getParty());
if (PartyManager.getInstance().canInvite(player, playerProfile)) {
Party party = playerProfile.getParty();
Users.getProfile(target).setInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", new Object[] {party.getName(), player.getName()}));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PCommand implements CommandExecutor {
@@ -30,7 +31,6 @@ public class PCommand implements CommandExecutor {
return true;
}
switch (args.length) {
case 0:
if (sender instanceof Player) {
@@ -58,9 +58,9 @@ public class PCommand implements CommandExecutor {
default:
if (sender instanceof Player) {
Player player = (Player) sender;
PP = Users.getProfile(player);
Party party = Users.getProfile(player).getParty();
if (!PP.inParty()) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
@@ -71,13 +71,20 @@ public class PCommand implements CommandExecutor {
message = message + " " + args [i];
}
if (PP.getPartyChatMode()) {
player.chat(message);
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), party.getName(), message);
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return true;
}
else {
PP.togglePartyChat();
player.chat(message);
PP.togglePartyChat();
message = chatEvent.getMessage();
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + player.getName() + ChatColor.GREEN + ") ";
plugin.getLogger().info("[P](" + party.getName() + ")" + "<" + player.getName() + "> " + message);
for (Player member : party.getOnlineMembers()) {
member.sendMessage(prefix + message);
}
}
else {
@@ -86,7 +93,7 @@ public class PCommand implements CommandExecutor {
return true;
}
if (!Party.getInstance().isParty(args[0])) {
if (!PartyManager.getInstance().isParty(args[0])) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}
@@ -109,8 +116,8 @@ public class PCommand implements CommandExecutor {
plugin.getLogger().info("[P](" + args[0] + ")" + "<*Console*> " + message);
for (Player player : Party.getInstance().getOnlineMembers(args[0])) {
player.sendMessage(prefix + message);
for (Player member : PartyManager.getInstance().getOnlineMembers(args[0])) {
member.sendMessage(prefix + message);
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.commands.party;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -13,6 +14,7 @@ import com.gmail.nossr50.events.party.McMMOPartyChangeEvent;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PartyCommand implements CommandExecutor {
@@ -34,60 +36,54 @@ public class PartyCommand implements CommandExecutor {
Player player = (Player) sender;
String playerName = player.getName();
PlayerProfile PP = Users.getProfile(player);
PlayerProfile playerProfile = Users.getProfile(player);
Party partyInstance = Party.getInstance();
boolean inParty = PP.inParty();
String partyName = PP.getParty();
boolean isLeader = partyInstance.isPartyLeader(playerName, partyName);
if (PP.inParty() && (!partyInstance.isParty(PP.getParty()) || !partyInstance.isInParty(player, PP))) {
partyInstance.addToParty(player, PP, PP.getParty(), false, null);
}
PartyManager partyManagerInstance = PartyManager.getInstance();
Party party = playerProfile.getParty();
switch (args.length) {
case 0:
if (!inParty) {
if (party == null) {
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
}
else {
String tempList = "";
Server server = plugin.getServer();
String leader = party.getLeader();
StringBuffer tempList = new StringBuffer();
for (Player p : partyInstance.getAllMembers(player)) {
if (p.equals(partyInstance.getPartyLeader(partyName))) {
tempList = ChatColor.GOLD + p.getName();
for (String otherPlayerName : party.getMembers()) {
if (leader.equals(otherPlayerName)) {
tempList.append(ChatColor.GOLD);
}
else if (server.getPlayer(otherPlayerName) != null) {
tempList.append(ChatColor.WHITE);
}
else {
tempList = ChatColor.WHITE + p.getName();
tempList.append(ChatColor.GRAY);
}
tempList.append(otherPlayerName + " ");
}
if (isLeader) {
tempList += ChatColor.GOLD + playerName;
}
else {
tempList += ChatColor.WHITE + playerName;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] { partyName }));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] { tempList }));
player.sendMessage(LocaleLoader.getString("Commands.Party.InParty", new Object[] {party.getName()}));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", new Object[] {tempList}));
}
return true;
case 1:
if (args[0].equalsIgnoreCase("q")) {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY);
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
@@ -103,13 +99,13 @@ public class PartyCommand implements CommandExecutor {
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
}
else if (args[0].equalsIgnoreCase("lock")) {
if (inParty) {
if (isLeader) {
if (partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
}
else {
partyInstance.lockParty(partyName);
party.setLocked(true);
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
}
@@ -122,13 +118,13 @@ public class PartyCommand implements CommandExecutor {
}
}
else if (args[0].equalsIgnoreCase("unlock")) {
if (inParty) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
if (party != null) {
if (party.getLeader().equals(playerName)) {
if (!party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
}
else {
partyInstance.unlockParty(partyName);
party.setLocked(false);
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
}
@@ -141,15 +137,15 @@ public class PartyCommand implements CommandExecutor {
}
}
else {
if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyManagerInstance.removeFromParty(playerName, party);
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
@@ -160,58 +156,40 @@ public class PartyCommand implements CommandExecutor {
}
}
partyInstance.addToParty(player, PP, args[0], false, null);
partyManagerInstance.joinParty(player, playerProfile, args[0], null);
}
return true;
case 2:
if (!partyInstance.isParty(args[0])) {
sender.sendMessage(LocaleLoader.getString("Party.InvalidName"));
return true;
}
if (PP.inParty()) {
if (playerProfile.inParty()) {
if (args[0].equalsIgnoreCase("password")) {
if (isLeader) {
if (!partyInstance.isPartyLocked(partyName)) {
partyInstance.lockParty(partyName);
}
partyInstance.setPartyPassword(partyName, args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] { args[1] }));
if (party.getLeader().equals(playerName)) {
party.setLocked(true);
party.setPassword(args[1]);
player.sendMessage(LocaleLoader.getString("Party.PasswordSet", new Object[] {args[1]}));
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else if (args[0].equalsIgnoreCase("kick")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
PlayerProfile PPt = Users.getProfile(target);
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
else {
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(target, PPt);
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", new Object[] { partyName }));
partyManagerInstance.removeFromParty(args[1], party);
}
}
else {
@@ -219,39 +197,26 @@ public class PartyCommand implements CommandExecutor {
}
}
else if (args[0].equalsIgnoreCase("owner")) {
if (isLeader) {
Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] {args[1]}));
return true;
}
String targetName = target.getName();
if (!partyInstance.inSameParty(player, (Player) target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", new Object[] { targetName }));
return true;
}
else {
partyInstance.setPartyLeader(partyName, targetName);
partyManagerInstance.setPartyLeader(args[1], party);
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
}
else {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES);
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
partyInstance.removeFromParty(player, PP);
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.removeFromParty(playerName, party);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
}
else {
@@ -262,7 +227,7 @@ public class PartyCommand implements CommandExecutor {
return true;
}
partyInstance.addToParty(player, PP, args[0], false, args[1]);
partyManagerInstance.joinParty(player, playerProfile, args[0], args[1]);
}
return true;

View File

@@ -12,7 +12,7 @@ import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class PtpCommand implements CommandExecutor {
@@ -39,11 +39,6 @@ public class PtpCommand implements CommandExecutor {
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
if (!Party.getInstance().isInParty(player, PP)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
if (PP.getRecentlyHurt() + (Config.getInstance().getPTPCommandCooldown() * 1000) > System.currentTimeMillis()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Hurt", new Object[] { Config.getInstance().getPTPCommandCooldown() }));
return true;
@@ -57,7 +52,7 @@ public class PtpCommand implements CommandExecutor {
}
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Invalid"));
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
@@ -66,8 +61,8 @@ public class PtpCommand implements CommandExecutor {
return true;
}
if (Party.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
if (PartyManager.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {

View File

@@ -1,20 +1,10 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsCommand implements CommandExecutor {
private float skillValue;
public class AcrobaticsCommand extends SkillCommand {
private String dodgeChance;
private String rollChance;
private String gracefulRollChance;
@@ -23,31 +13,48 @@ public class AcrobaticsCommand implements CommandExecutor {
private boolean canRoll;
private boolean canGracefulRoll;
public AcrobaticsCommand() {
super(SkillType.ACROBATICS);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
if (skillValue >= 1000) {
dodgeChance = "20.00%";
rollChance = "100.00%";
gracefulRollChance = "100.00%";
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.acrobatics")) {
return true;
else if (skillValue >= 800) {
dodgeChance = "20.00%";
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100.00%";
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.ACROBATICS);
dataCalculations(skillValue);
permissionsCheck(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Acrobatics.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Acrobatics") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
else if (skillValue >= 500) {
dodgeChance = percent.format(skillValue / 4000);
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = "100.00%";
}
else {
dodgeChance = percent.format(skillValue / 4000);
rollChance = percent.format(skillValue / 1000);
gracefulRollChance = percent.format(skillValue / 500);
}
}
@Override
protected void permissionsCheck() {
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void effectsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.0"), LocaleLoader.getString("Acrobatics.Effect.1") }));
}
@@ -59,11 +66,15 @@ public class AcrobaticsCommand implements CommandExecutor {
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Acrobatics.Effect.4"), LocaleLoader.getString("Acrobatics.Effect.5") }));
}
}
if (canDodge || canGracefulRoll || canRoll) {
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
}
@Override
protected boolean statsHeaderPermissions() {
return canDodge || canGracefulRoll || canRoll;
}
@Override
protected void statsDisplay() {
if (canRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Chance", new Object[] { rollChance }));
}
@@ -75,39 +86,5 @@ public class AcrobaticsCommand implements CommandExecutor {
if (canDodge) {
player.sendMessage(LocaleLoader.getString("Acrobatics.DodgeChance", new Object[] { dodgeChance }));
}
Page.grabGuidePageForSkill(SkillType.ACROBATICS, player, args);
return true;
}
private void dataCalculations(float skillValue) {
if (skillValue >= 1000) {
dodgeChance = "20";
rollChance = "100";
gracefulRollChance = "100";
}
else if (skillValue >= 800) {
dodgeChance = "20";
rollChance = String.valueOf(skillValue / 10);
gracefulRollChance = "100";
}
else if (skillValue >= 500) {
dodgeChance = String.valueOf(skillValue / 40);
rollChance = String.valueOf(skillValue / 10);
gracefulRollChance = "100";
}
else {
dodgeChance = String.valueOf(skillValue / 40);
rollChance = String.valueOf(skillValue / 10);
gracefulRollChance = String.valueOf(skillValue / 5);
}
}
private void permissionsCheck(Player player) {
Permissions permInstance = Permissions.getInstance();
canDodge = permInstance.dodge(player);
canRoll = permInstance.roll(player);
canGracefulRoll = permInstance.gracefulRoll(player);
}
}

View File

@@ -1,68 +1,80 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class ArcheryCommand implements CommandExecutor {
private float skillValue;
public class ArcheryCommand extends SkillCommand {
private String skillShotBonus;
private String dazeChance;
private String retrieveChance;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canSkillShot;
private boolean canDaze;
private boolean canRetrieve;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.archery")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.ARCHERY);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Archery.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Archery") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
Page.grabGuidePageForSkill(SkillType.ARCHERY, player, args);
return true;
public ArcheryCommand() {
super(SkillType.ARCHERY);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
if (skillValue >= 1000) {
skillShotBonus = "200";
dazeChance = "50";
retrieveChance = "100";
skillShotBonus = "200.00%";
dazeChance = "50.00%";
retrieveChance = "100.00%";
}
else {
skillShotBonus = String.valueOf((int) skillValue / 5);
dazeChance = String.valueOf(skillValue / 20);
retrieveChance = String.valueOf(skillValue / 10);
skillShotBonus = percent.format(((int) skillValue / 50) * 0.1D); //TODO: Not sure if this is the best way to calculate this or not...
dazeChance = percent.format(skillValue / 2000);
retrieveChance = percent.format(skillValue / 1000);
}
}
@Override
protected void permissionsCheck() {
canSkillShot = permInstance.archeryBonus(player);
canDaze = permInstance.daze(player);
canRetrieve = permInstance.trackArrows(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void effectsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.0"), LocaleLoader.getString("Archery.Effect.1") }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.2"), LocaleLoader.getString("Archery.Effect.3") }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Archery.Effect.4"), LocaleLoader.getString("Archery.Effect.5") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkillShot || canDaze || canRetrieve;
}
@Override
protected void statsDisplay() {
if (canSkillShot) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.SkillshotBonus", new Object[] { skillShotBonus }));
}
if (canDaze) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.DazeChance", new Object[] { dazeChance }));
}
if (canRetrieve) {
player.sendMessage(LocaleLoader.getString("Archery.Combat.RetrieveChance", new Object[] { retrieveChance }));
}
}
}

View File

@@ -1,84 +1,108 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class AxesCommand implements CommandExecutor {
private float skillValue;
public class AxesCommand extends SkillCommand {
private String critChance;
private String bonusDamage;
private String impactDamage;
private String greaterImpactDamage;
private String skullSplitterLength;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canSkullSplitter;
private boolean canCritical;
private boolean canBonusDamage;
private boolean canImpact;
private boolean canGreaterImpact;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.axes")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.AXES);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Axes.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Axes") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
return true;
public AxesCommand() {
super(SkillType.AXES);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
impactDamage = String.valueOf(5 + ((int) skillValue / 30));
skullSplitterLength = String.valueOf(2 + ((int) skillValue / 50));
greaterImpactDamage = "2";
if (skillValue >= 1000) {
critChance = "37.5";
if (skillValue >= 750) {
critChance = "37.50";
bonusDamage = "4";
greaterImpactDamage = "2";
}
else if (skillValue >= 750) {
critChance = "37.5";
bonusDamage = "4";
greaterImpactDamage = "2";
}
else if (skillValue >= 200) {
critChance = String.valueOf(skillValue / 20);
critChance = percent.format(skillValue / 2000);
bonusDamage = "4";
greaterImpactDamage = "2";
}
else {
critChance = String.valueOf(skillValue / 20);
critChance = percent.format(skillValue / 2000);
bonusDamage = String.valueOf((int) skillValue / 50);
greaterImpactDamage = "2";
}
}
@Override
protected void permissionsCheck() {
canSkullSplitter = permInstance.skullSplitter(player);
canCritical = permInstance.criticalHit(player);
canBonusDamage = permInstance.axeBonus(player);
canImpact = permInstance.impact(player);
canGreaterImpact = permInstance.greaterImpact(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void effectsDisplay() {
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.0"), LocaleLoader.getString("Axes.Effect.1") }));
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.2"), LocaleLoader.getString("Axes.Effect.3") }));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.4"), LocaleLoader.getString("Axes.Effect.5") }));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.6"), LocaleLoader.getString("Axes.Effect.7") }));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Axes.Effect.8"), LocaleLoader.getString("Axes.Effect.9") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canSkullSplitter || canCritical || canBonusDamage || canImpact || canGreaterImpact;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.0"), LocaleLoader.getString("Axes.Ability.Bonus.1", new Object[] {bonusDamage}) }));
}
if (canImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.2"), LocaleLoader.getString("Axes.Ability.Bonus.3", new Object[] {impactDamage}) }));
}
if (canGreaterImpact) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Axes.Ability.Bonus.4"), LocaleLoader.getString("Axes.Ability.Bonus.5", new Object[] {greaterImpactDamage}) }));
}
if (canCritical) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.CritChance", new Object[] { critChance }));
}
if (canSkullSplitter) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.SS.Length", new Object[] { skullSplitterLength }));
}
}
}

View File

@@ -1,54 +1,55 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class ExcavationCommand implements CommandExecutor {
private float skillValue;
public class ExcavationCommand extends SkillCommand {
private String gigaDrillBreakerLength;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canGigaDrill;
private boolean canTreasureHunt;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.excavation")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.EXCAVATION);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Excavation.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Excavation") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
Page.grabGuidePageForSkill(SkillType.EXCAVATION, player, args);
return true;
public ExcavationCommand() {
super(SkillType.EXCAVATION);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
gigaDrillBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
}
@Override
protected void permissionsCheck() {
canGigaDrill = permInstance.gigaDrillBreaker(player);
canTreasureHunt = permInstance.excavationTreasures(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canGigaDrill || canTreasureHunt;
}
@Override
protected void effectsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.0"), LocaleLoader.getString("Excavation.Effect.1") }));
}
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Excavation.Effect.2"), LocaleLoader.getString("Excavation.Effect.3") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGigaDrill;
}
@Override
protected void statsDisplay() {
if (canGigaDrill) {
player.sendMessage(LocaleLoader.getString("Excavation.Effect.Length", new Object[] { gigaDrillBreakerLength }));
}
}
}

View File

@@ -1,55 +1,78 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Fishing;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.skills.gathering.Fishing;
public class FishingCommand extends SkillCommand {
private int lootTier;
private String magicChance;
private boolean canTreasureHunt;
private boolean canMagicHunt;
private boolean canShake;
public FishingCommand() {
super(SkillType.FISHING);
}
public class FishingCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
protected void dataCalculations() {
lootTier = Fishing.getFishingLootTier(profile);
magicChance = percent.format((float) lootTier / 15);
}
@Override
protected void permissionsCheck() {
canTreasureHunt = permInstance.fishingTreasures(player);
canMagicHunt = permInstance.fishingMagic(player);
canShake = permInstance.shakeMob(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void effectsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.fishing")) {
return true;
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Fishing.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Fishing") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.0"), LocaleLoader.getString("Fishing.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.2"), LocaleLoader.getString("Fishing.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { Fishing.getFishingLootTier(PP) }));
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Info"));
//TODO: Do we really need to display this twice? Not like there are any associated stats.
if (PP.getSkillLevel(SkillType.FISHING) < 150) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
if (canShake) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Fishing.Effect.4"), LocaleLoader.getString("Fishing.Effect.5") }));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
}
@Override
protected boolean statsHeaderPermissions() {
return canTreasureHunt || canMagicHunt || canShake;
}
@Override
protected void statsDisplay() {
if (canTreasureHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Rank", new Object[] { lootTier }));
}
Page.grabGuidePageForSkill(SkillType.FISHING, player, args);
if (canMagicHunt) {
player.sendMessage(LocaleLoader.getString("Fishing.Enchant.Chance", new Object[] { magicChance }));
}
return true;
if (canShake) {
//TODO: Do we really need to display this twice? Not like there are any associated stats.
if (skillValue < 150) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Fishing.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Fishing.Ability.Shake"));
}
}
}
}

View File

@@ -1,108 +1,141 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class HerbalismCommand implements CommandExecutor {
private float skillValue;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
private String greenThumbChance;
private String greenThumbStage;
private String farmersDietRank;
private String doubleDropChance;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canGreenTerra;
private boolean canGreenThumbWheat;
private boolean canGreenThumbBlocks;
private boolean canFarmersDiet;
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.herbalism")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.HERBALISM);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Herbalism.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Herbalism") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
Page.grabGuidePageForSkill(SkillType.HERBALISM, player, args);
return true;
public HerbalismCommand() {
super(SkillType.HERBALISM);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
greenTerraLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1500) {
greenThumbChance = "100";
greenThumbChance = "100.00%";
greenThumbStage = "4";
farmersDietRank = "5";
doubleDropChance = "100";
doubleDropChance = "100.00%";
}
else if (skillValue >= 1000) {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "5";
doubleDropChance = "100";
doubleDropChance = "100.00%";
}
else if (skillValue >= 800) {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "4";
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 600) {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "4";
farmersDietRank = "3";
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 400) {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "3";
farmersDietRank = "2";
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 200) {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "2";
farmersDietRank = "1";
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
else {
greenThumbChance = String.valueOf(skillValue / 15);
greenThumbChance = percent.format(skillValue / 1500);
greenThumbStage = "1";
farmersDietRank = "1";
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
}
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
canGreenTerra = permInstance.greenTerra(player);
canGreenThumbWheat = permInstance.greenThumbWheat(player);
canGreenThumbBlocks = permInstance.greenThumbBlocks(player);
canFarmersDiet = permInstance.farmersDiet(player);
canDoubleDrop = permInstance.herbalismDoubleDrops(player);
doubleDropsDisabled = configInstance.herbalismDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void effectsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.0"), LocaleLoader.getString("Herbalism.Effect.1") }));
}
if (canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.2"), LocaleLoader.getString("Herbalism.Effect.3") }));
}
if (canGreenThumbBlocks) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.4"), LocaleLoader.getString("Herbalism.Effect.5") }));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.6"), LocaleLoader.getString("Herbalism.Effect.7") }));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Herbalism.Effect.8"), LocaleLoader.getString("Herbalism.Effect.9") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canGreenTerra || (canDoubleDrop && !doubleDropsDisabled) || canFarmersDiet || canGreenThumbBlocks || canGreenThumbWheat;
}
@Override
protected void statsDisplay() {
if (canGreenTerra) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.Length", new Object[] { greenTerraLength }));
}
if (canGreenThumbBlocks || canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Chance", new Object[] { greenThumbChance }));
}
if (canGreenThumbWheat) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTh.Stage", new Object[] { greenThumbStage }));
}
if (canFarmersDiet) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.FD", new Object[] { farmersDietRank } ));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.DoubleDropChance", new Object[] { doubleDropChance }));
}
}
}

View File

@@ -1,138 +1,169 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.Misc;
public class MiningCommand implements CommandExecutor {
private float skillValue;
public class MiningCommand extends SkillCommand {
private String doubleDropChance;
private String superBreakerLength;
private int blastMiningRank;
private int blastRadiusIncrease;
private int blastDamageDecrease;
private String blastMiningRank;
private String blastRadiusIncrease;
private String blastDamageDecrease;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canSuperBreaker;
private boolean canDoubleDrop;
private boolean canBlast;
private boolean canBiggerBombs;
private boolean canDemoExpert;
private boolean doubleDropsDisabled;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.mining")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.MINING);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Mining.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Mining") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
if (PP.getSkillLevel(SkillType.MINING) < 125) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (blastMiningRank - 1)) }));
}
if (PP.getSkillLevel(SkillType.MINING) < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
}
if (PP.getSkillLevel(SkillType.MINING) < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
}
Page.grabGuidePageForSkill(SkillType.MINING, player, args);
return true;
public MiningCommand() {
super(SkillType.MINING);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
superBreakerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
blastMiningRank = 8;
blastDamageDecrease = 100;
blastRadiusIncrease = 4;
doubleDropChance = "100";
blastMiningRank = "8";
blastDamageDecrease = "100.00%";
blastRadiusIncrease = "4";
doubleDropChance = "100.00%";
}
else if (skillValue >= 875) {
blastMiningRank = 7;
blastDamageDecrease = 50;
blastRadiusIncrease = 3;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "7";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 750) {
blastMiningRank = 6;
blastDamageDecrease = 50;
blastRadiusIncrease = 3;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "6";
blastDamageDecrease = "50.00%";
blastRadiusIncrease = "3";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 625) {
blastMiningRank = 5;
blastDamageDecrease = 25;
blastRadiusIncrease = 2;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "5";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 500) {
blastMiningRank = 4;
blastDamageDecrease = 25;
blastRadiusIncrease = 2;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "4";
blastDamageDecrease = "25.00%";
blastRadiusIncrease = "2";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 375) {
blastMiningRank = 3;
blastDamageDecrease = 0;
blastRadiusIncrease = 1;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "3";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 250) {
blastMiningRank = 2;
blastDamageDecrease = 0;
blastRadiusIncrease = 1;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "2";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "1";
doubleDropChance = percent.format(skillValue / 1000);
}
else if (skillValue >= 125) {
blastMiningRank = 1;
blastDamageDecrease = 0;
blastRadiusIncrease = 0;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "1";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
doubleDropChance = percent.format(skillValue / 1000);
}
else {
blastMiningRank = 0;
blastDamageDecrease = 0;
blastRadiusIncrease = 0;
doubleDropChance = String.valueOf(skillValue / 10);
blastMiningRank = "0";
blastDamageDecrease = "0.00%";
blastRadiusIncrease = "0";
doubleDropChance = percent.format(skillValue / 1000);
}
}
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
canBiggerBombs = permInstance.biggerBombs(player);
canBlast = permInstance.blastMining(player);
canDemoExpert = permInstance.demolitionsExpertise(player);
canDoubleDrop = permInstance.miningDoubleDrops(player);
canSuperBreaker = permInstance.superBreaker(player);
doubleDropsDisabled = configInstance.miningDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void effectsDisplay() {
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.0"), LocaleLoader.getString("Mining.Effect.1") }));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.2"), LocaleLoader.getString("Mining.Effect.3") }));
}
if (canBlast) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.4"), LocaleLoader.getString("Mining.Effect.5") }));
}
if (canBiggerBombs) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.6"), LocaleLoader.getString("Mining.Effect.7") }));
}
if (canDemoExpert) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Mining.Effect.8"), LocaleLoader.getString("Mining.Effect.9") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBiggerBombs || canBlast || canDemoExpert || (canDoubleDrop && !doubleDropsDisabled) || canSuperBreaker;
}
@Override
protected void statsDisplay() {
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Mining.Effect.DropChance", new Object[] { doubleDropChance }));
}
if (canSuperBreaker) {
player.sendMessage(LocaleLoader.getString("Mining.Ability.Length", new Object[] { superBreakerLength }));
}
if (canBlast) {
if (skillValue < 125) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Rank", new Object[] { blastMiningRank, LocaleLoader.getString("Mining.Blast.Effect." + (Misc.getInt(blastMiningRank) - 1)) }));
}
}
if (canBiggerBombs) {
if (skillValue < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.1") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Blast.Radius.Increase", new Object[] { blastRadiusIncrease }));
}
}
if (canDemoExpert) {
if (skillValue < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Mining.Ability.Locked.2") }));
}
else {
player.sendMessage(LocaleLoader.getString("Mining.Effect.Decrease", new Object[] { blastDamageDecrease }));
}
}
}
}

View File

@@ -1,73 +1,142 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Repairable;
public class RepairCommand implements CommandExecutor {
private float skillValue;
public class RepairCommand extends SkillCommand {
private int arcaneForgingRank;
private String repairMasteryBonus;
private String superRepairChance;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canSuperRepair;
private boolean canMasterRepair;
private boolean canArcaneForge;
private boolean canRepairStone;
private boolean canRepairIron;
private boolean canRepairGold;
private boolean canRepairDiamond;
private boolean canRepairString;
private boolean canRepairLeather;
private boolean canRepairWood;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.repair")) {
return true;
}
private int diamondLevel;
private int goldLevel;
private int ironLevel;
private int stoneLevel;
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.REPAIR);
dataCalculations(skillValue);
int arcaneForgingRank = Repair.getArcaneForgingRank(PP);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Repair.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Repair") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { Config.getInstance().getRepairDiamondLevelRequirement() }), LocaleLoader.getString("Repair.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
Page.grabGuidePageForSkill(SkillType.REPAIR, player, args);
return true;
public RepairCommand() {
super(SkillType.REPAIR);
}
private void dataCalculations(float skillValue) {
repairMasteryBonus = String.valueOf(skillValue / 5);
@Override
protected void dataCalculations() {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
repairMasteryBonus = percent.format(skillValue / 500);
if (skillValue >= 1000) {
superRepairChance = "100";
superRepairChance = "100.00%";
}
else {
superRepairChance = String.valueOf(skillValue / 10);
superRepairChance = percent.format(skillValue / 1000);
}
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
}
@Override
protected void permissionsCheck() {
canSuperRepair = permInstance.repairBonus(player);
canMasterRepair = permInstance.repairMastery(player);
canArcaneForge = permInstance.arcaneForging(player);
canRepairDiamond = permInstance.diamondRepair(player);
canRepairGold = permInstance.goldRepair(player);
canRepairIron = permInstance.ironRepair(player);
canRepairStone = permInstance.stoneRepair(player);
canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canArcaneForge || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
}
@Override
protected void effectsDisplay() {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
}
/* Repair Level Requirements */
if (canRepairStone && stoneLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.14", new Object[] { stoneLevel }), LocaleLoader.getString("Repair.Effect.15") }));
}
if (canRepairIron && ironLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.12", new Object[] { ironLevel }), LocaleLoader.getString("Repair.Effect.13") }));
}
if (canRepairGold && goldLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.10", new Object[] { goldLevel }), LocaleLoader.getString("Repair.Effect.11") }));
}
if (canRepairDiamond && diamondLevel > 0) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canArcaneForge || canMasterRepair || canSuperRepair;
}
@Override
protected void statsDisplay() {
if (canMasterRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
}
if (canSuperRepair) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
}
if (canArcaneForge) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
}
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
}
}
}
}

View File

@@ -1,79 +1,91 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class SwordsCommand implements CommandExecutor {
private float skillValue;
public class SwordsCommand extends SkillCommand {
private String counterAttackChance;
private String bleedLength;
private String bleedChance;
private String serratedStrikesLength;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canCounter;
private boolean canSerratedStrike;
private boolean canBleed;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.swords")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.SWORDS);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Swords.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Swords") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
Page.grabGuidePageForSkill(SkillType.SWORDS, player, args);
return true;
public SwordsCommand() {
super(SkillType.SWORDS);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
serratedStrikesLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 750) {
bleedLength = "3";
bleedChance = "75";
counterAttackChance = "30";
bleedChance = "75.00%";
counterAttackChance = "30.00%";
}
else if (skillValue >= 600) {
bleedLength = "2";
bleedChance = String.valueOf(skillValue / 10);
counterAttackChance = "30";
bleedChance = percent.format(skillValue / 1000);
counterAttackChance = "30.00%";
}
else {
bleedLength = "2";
bleedChance = String.valueOf(skillValue / 10);
counterAttackChance = String.valueOf(skillValue / 20);
bleedChance = percent.format(skillValue / 1000);
counterAttackChance = percent.format(skillValue / 2000);
}
}
@Override
protected void permissionsCheck() {
canBleed = permInstance.swordsBleed(player);
canCounter = permInstance.counterAttack(player);
canSerratedStrike = permInstance.serratedStrikes(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void effectsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.0"), LocaleLoader.getString("Swords.Effect.1") }));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.2"), LocaleLoader.getString("Swords.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.4"), LocaleLoader.getString("Swords.Effect.5") }));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Swords.Effect.6"), LocaleLoader.getString("Swords.Effect.7") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBleed || canCounter || canSerratedStrike;
}
@Override
protected void statsDisplay() {
if (canCounter) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Chance", new Object[] { counterAttackChance }));
}
if (canBleed) {
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Length", new Object[] { bleedLength }));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Note"));
player.sendMessage(LocaleLoader.getString("Swords.Combat.Bleed.Chance", new Object[] { bleedChance }));
}
if (canSerratedStrike) {
player.sendMessage(LocaleLoader.getString("Swords.SS.Length", new Object[] { serratedStrikesLength }));
}
}
}

View File

@@ -1,104 +1,145 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class TamingCommand implements CommandExecutor {
private float skillValue;
public class TamingCommand extends SkillCommand {
private String goreChance;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canBeastLore;
private boolean canGore;
private boolean canSharpenedClaws;
private boolean canEnvironmentallyAware;
private boolean canThickFur;
private boolean canShockProof;
private boolean canCallWild;
private boolean canFastFood;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.taming")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.TAMING);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Taming.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Taming") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { Config.getInstance().getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { Config.getInstance().getTamingCOTWWolfCost() }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
if (PP.getSkillLevel(SkillType.TAMING) < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 750) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
}
if (PP.getSkillLevel(SkillType.TAMING) < 50) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9 ") }));
}
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
Page.grabGuidePageForSkill(SkillType.TAMING, player, args);
return true;
public TamingCommand() {
super(SkillType.TAMING);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
if (skillValue >= 1000) {
goreChance = "100";
goreChance = "100.00%";
}
else {
goreChance = String.valueOf(skillValue / 10);
goreChance = percent.format(skillValue / 1000);
} }
@Override
protected void permissionsCheck() {
canBeastLore = permInstance.beastLore(player);
canCallWild = permInstance.callOfTheWild(player);
canEnvironmentallyAware = permInstance.environmentallyAware(player);
canFastFood = permInstance.fastFoodService(player);
canGore = permInstance.gore(player);
canSharpenedClaws = permInstance.sharpenedClaws(player);
canShockProof = permInstance.shockProof(player);
canThickFur = permInstance.thickFur(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBeastLore || canCallWild || canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
@Override
protected void effectsDisplay() {
Config configInstance = Config.getInstance();
if (canBeastLore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.0"), LocaleLoader.getString("Taming.Effect.1") }));
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.2"), LocaleLoader.getString("Taming.Effect.3") }));
}
if (canSharpenedClaws) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.4"), LocaleLoader.getString("Taming.Effect.5") }));
}
if (canEnvironmentallyAware) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.6"), LocaleLoader.getString("Taming.Effect.7") }));
}
if (canThickFur) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.8"), LocaleLoader.getString("Taming.Effect.9") }));
}
if (canShockProof) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.10"), LocaleLoader.getString("Taming.Effect.11") }));
}
if (canFastFood) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.16"), LocaleLoader.getString("Taming.Effect.17") }));
}
if (canCallWild) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Taming.Effect.12"), LocaleLoader.getString("Taming.Effect.13") }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.14", new Object[] { configInstance.getTamingCOTWOcelotCost() }));
player.sendMessage(LocaleLoader.getString("Taming.Effect.15", new Object[] { configInstance.getTamingCOTWWolfCost() }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canEnvironmentallyAware || canFastFood || canGore || canSharpenedClaws || canShockProof || canThickFur;
}
@Override
protected void statsDisplay() {
if (canFastFood) {
if (skillValue < 50) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.4") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.8"), LocaleLoader.getString("Taming.Ability.Bonus.9") }));
}
}
if (canEnvironmentallyAware) {
if (skillValue < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.0"), LocaleLoader.getString("Taming.Ability.Bonus.1") }));
}
}
if (canThickFur) {
if (skillValue < 250) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.1") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.2"), LocaleLoader.getString("Taming.Ability.Bonus.3") }));
}
}
if (canShockProof) {
if (skillValue < 500) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.2") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.4"), LocaleLoader.getString("Taming.Ability.Bonus.5") }));
}
}
if (canSharpenedClaws) {
if (skillValue < 750) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Taming.Ability.Locked.3") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Taming.Ability.Bonus.6"), LocaleLoader.getString("Taming.Ability.Bonus.7") }));
}
}
if (canGore) {
player.sendMessage(LocaleLoader.getString("Taming.Combat.Chance.Gore", new Object[] { goreChance }));
}
}
}

View File

@@ -1,78 +1,97 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class UnarmedCommand implements CommandExecutor {
private float skillValue;
public class UnarmedCommand extends SkillCommand {
private String berserkLength;
private String deflectChance;
private String disarmChance;
private String ironArmBonus;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canBerserk;
private boolean canDisarm;
private boolean canBonusDamage;
private boolean canDeflect;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.unarmed")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Unarmed.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.Unarmed") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
Page.grabGuidePageForSkill(SkillType.UNARMED, player, args);
return true;
public UnarmedCommand() {
super(SkillType.UNARMED);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
berserkLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
disarmChance = "33.3";
deflectChance = "50";
disarmChance = "33.33%";
deflectChance = "50.00%";
ironArmBonus = "8";
}
else if (skillValue >= 250) {
disarmChance = String.valueOf(skillValue / 30);
deflectChance = String.valueOf(skillValue / 20);
disarmChance = percent.format(skillValue / 3000);
deflectChance = percent.format(skillValue / 2000);
ironArmBonus = "8";
}
else {
disarmChance = String.valueOf(skillValue / 30);
deflectChance = String.valueOf(skillValue / 20);
disarmChance = percent.format(skillValue / 3000);
deflectChance = percent.format(skillValue / 2000);
ironArmBonus = String.valueOf(3 + ((int) skillValue / 50));
} }
@Override
protected void permissionsCheck() {
canBerserk = permInstance.berserk(player);
canBonusDamage = permInstance.unarmedBonus(player);
canDeflect = permInstance.deflect(player);
canDisarm = permInstance.disarm(player);
}
@Override
protected boolean effectsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void effectsDisplay() {
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.0"), LocaleLoader.getString("Unarmed.Effect.1") }));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.2"), LocaleLoader.getString("Unarmed.Effect.3") }));
}
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.4"), LocaleLoader.getString("Unarmed.Effect.5") }));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Unarmed.Effect.6"), LocaleLoader.getString("Unarmed.Effect.7") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return canBerserk || canBonusDamage || canDeflect || canDisarm;
}
@Override
protected void statsDisplay() {
if (canBonusDamage) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Unarmed.Ability.Bonus.0"), LocaleLoader.getString("Unarmed.Ability.Bonus.1", new Object[] {ironArmBonus}) }));
}
if (canDeflect) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.ArrowDeflect", new Object[] { deflectChance }));
}
if (canDisarm) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Chance.Disarm", new Object[] { disarmChance }));
}
if (canBerserk) {
player.sendMessage(LocaleLoader.getString("Unarmed.Ability.Berserk.Length", new Object[] { berserkLength }));
}
}
}

View File

@@ -1,72 +1,88 @@
package com.gmail.nossr50.commands.skills;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.SkillCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Page;
import com.gmail.nossr50.util.Users;
public class WoodcuttingCommand implements CommandExecutor {
private float skillValue;
public class WoodcuttingCommand extends SkillCommand {
private String treeFellerLength;
private String doubleDropChance;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
private boolean canTreeFell;
private boolean canLeafBlow;
private boolean canDoubleDrop;
private boolean doubleDropsDisabled;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.skills.woodcutting")) {
return true;
}
Player player = (Player) sender;
PlayerProfile PP = Users.getProfile(player);
skillValue = (float) PP.getSkillLevel(SkillType.UNARMED);
dataCalculations(skillValue);
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("WoodCutting.SkillName") }));
player.sendMessage(LocaleLoader.getString("Commands.XPGain", new Object[] { LocaleLoader.getString("Commands.XPGain.WoodCutting") }));
player.sendMessage(LocaleLoader.getString("Effects.Level", new Object[] { PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Effects.Effects") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
player.sendMessage(LocaleLoader.getString("Skills.Header", new Object[] { LocaleLoader.getString("Commands.Stats.Self") }));
if (PP.getSkillLevel(SkillType.WOODCUTTING) < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
}
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
Page.grabGuidePageForSkill(SkillType.WOODCUTTING, player, args);
return true;
public WoodcuttingCommand() {
super(SkillType.WOODCUTTING);
}
private void dataCalculations(float skillValue) {
@Override
protected void dataCalculations() {
treeFellerLength = String.valueOf(2 + ((int) skillValue / 50));
if (skillValue >= 1000) {
doubleDropChance = "100";
doubleDropChance = "100.00%";
}
else {
doubleDropChance = String.valueOf(skillValue / 10);
doubleDropChance = percent.format(skillValue / 1000);
}
}
@Override
protected void permissionsCheck() {
Config configInstance = Config.getInstance();
canTreeFell = permInstance.treeFeller(player);
canDoubleDrop = permInstance.woodcuttingDoubleDrops(player);
canLeafBlow = permInstance.leafBlower(player);
doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled();
}
@Override
protected boolean effectsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void effectsDisplay() {
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") }));
}
if (canLeafBlow) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") }));
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") }));
}
}
@Override
protected boolean statsHeaderPermissions() {
return (canDoubleDrop && !doubleDropsDisabled) || canLeafBlow || canTreeFell;
}
@Override
protected void statsDisplay() {
//TODO: Remove? Basically duplicates the above.
if (canLeafBlow) {
if (skillValue < 100) {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0") }));
}
else {
player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") }));
}
}
if (canDoubleDrop && !doubleDropsDisabled) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }));
}
if (canTreeFell) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }));
}
}
}

View File

@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
@@ -32,7 +32,7 @@ public class MchudCommand implements CommandExecutor {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@@ -6,15 +6,17 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class XplockCommand implements CommandExecutor {
@@ -26,7 +28,7 @@ public class XplockCommand implements CommandExecutor {
return true;
}
if (!Config.getInstance().spoutEnabled || !Config.getInstance().getSpoutXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
if (!mcMMO.spoutEnabled || !SpoutConfig.getInstance().getXPBarEnabled() || !Config.getInstance().getCommandXPLockEnabled()) {
sender.sendMessage(LocaleLoader.getString("Commands.Disabled"));
return true;
}

View File

@@ -1,7 +1,11 @@
package com.gmail.nossr50.config;
import java.util.Iterator;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.HUDType;
public class Config extends ConfigLoader {
public int xpGainMultiplier = 1;
@@ -10,6 +14,7 @@ public class Config extends ConfigLoader {
public static Config getInstance() {
if (instance == null) {
instance = new Config(mcMMO.p);
instance.load();
}
return instance;
@@ -33,7 +38,8 @@ public class Config extends ConfigLoader {
public String getMySQLUserName() { return config.getString("MySQL.Database.User_Name", "UserName"); } //Really should be labeled under MySQL.User_Name instead...
public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
public String getMySQLUserPassword() {
public String getMySQLUserPassword() {
if (config.getString("MySQL.Database.User_Password", null) != null) {
return config.getString("MySQL.Database.User_Password", null);
}
@@ -42,6 +48,17 @@ public class Config extends ConfigLoader {
}
}
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
/* Commands */
public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); }
public boolean getCommandXPRateEnabled() { return config.getBoolean("Commands.xprate.Enabled", true); }
@@ -95,6 +112,16 @@ public class Config extends ConfigLoader {
public int getAbilityCooldownSkullSplitter() { return config.getInt("Abilities.Cooldowns.Skull_Splitter", 240); }
public int getAbilityCooldownBlastMining() { return config.getInt("Abilities.Cooldowns.Blast_Mining", 60); }
/* Max ticks */
public int getAbilityMaxTicksGreenTerra() { return config.getInt("Abilities.Max_Seconds.Green_Terra", 0); }
public int getAbilityMaxTicksSuperBreaker() { return config.getInt("Abilities.Max_Seconds.Super_Breaker", 0); }
public int getAbilityMaxTicksGigaDrillBreaker() { return config.getInt("Abilities.Max_Seconds.Giga_Drill_Breaker", 0); }
public int getAbilityMaxTicksTreeFeller() { return config.getInt("Abilities.Max_Seconds.Tree_Feller", 0); }
public int getAbilityMaxTicksBerserk() { return config.getInt("Abilities.Max_Seconds.Berserk", 0); }
public int getAbilityMaxTicksSerratedStrikes() { return config.getInt("Abilities.Max_Seconds.Serrated_Strikes", 0); }
public int getAbilityMaxTicksSkullSplitter() { return config.getInt("Abilities.Max_Seconds.Skull_Splitter", 0); }
public int getAbilityMaxTicksBlastMining() { return config.getInt("Abilities.Max_Seconds.Blast_Mining", 0); }
/* Thresholds */
public int getTreeFellerThreshold() { return config.getInt("Abilities.Limits.Tree_Feller_Threshold", 500); }
@@ -130,14 +157,45 @@ public class Config extends ConfigLoader {
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
public boolean getHerbalismHungerBonusEnabled() { return config.getBoolean("Skills.Herbalism.Hunger_Bonus", true); }
public boolean getHerbalismWheatRegrowth() { return config.getBoolean("Skills.Herbalism.Instant_Wheat_Regrowth", true); }
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
public boolean getBrownMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Brown_Mushrooms", true); }
public boolean getCactiDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cacti", true); }
public boolean getWheatDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Wheat", true); }
public boolean getMelonsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Melons", true); }
public boolean getNetherWartsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Nether_Warts", true); }
public boolean getPumpkinsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Pumpkins", true); }
public boolean getRedMushroomsDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Mushrooms", true); }
public boolean getRedRosesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Red_Roses", true); }
public boolean getSugarCaneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Sugar_Cane", true); }
public boolean getVinesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Vines", true); }
public boolean getWaterLiliesDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Water_Lilies", true); }
public boolean getYellowFlowersDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Yellow_Flowers", true); }
public boolean herbalismDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Herbalism");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Herbalism." + key)) {
disabled = false;
break;
}
}
return disabled;
}
/* Mining */
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPGoldOre() { return config.getInt("Experience.Mining.Gold", 250); }
public int getMiningXPDiamondOre() { return config.getInt("Experience.Mining.Diamond", 750); }
public int getMiningXPIronOre() { return config.getInt("Experience.Mining.Iron", 250); }
public int getMiningXPRedstoneOre() { return config.getInt("Experience.Mining.Redstone", 150); }
@@ -150,29 +208,46 @@ public class Config extends ConfigLoader {
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
public boolean getEndStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.End_Stone", true); }
public boolean getGlowstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Glowstone", true); }
public boolean getGoldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Gold", true); }
public boolean getIronDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Iron", true); }
public boolean getLapisDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Lapis", true); }
public boolean getMossyCobblestoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Moss_Stone", true); }
public boolean getNetherrackDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Netherrack", true); }
public boolean getObsidianDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Obsidian", true); }
public boolean getRedstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Redstone", true); }
public boolean getSandstoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Sandstone", true); }
public boolean getStoneDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Stone", true); }
public boolean miningDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Mining");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Mining." + key)) {
disabled = false;
break;
}
}
return disabled;
}
public int getDetonatorItemID() { return config.getInt("Skills.Mining.Detonator_ID", 259); }
/* Repair */
public boolean getRepairAnvilMessagesEnabled() { return config.getBoolean("Skills.Repair.Anvil_Messages", true); }
public int getRepairAnvilId() { return config.getInt("Skills.Repair.Anvil_ID", 42); }
public int getRepairGoldMaterial() { return config.getInt("Skills.Repair.Gold.ID", 266); }
public int getRepairStoneMaterial() { return config.getInt("Skills.Repair.Stone.ID", 4); }
public int getRepairWoodMaterial() { return config.getInt("Skills.Repair.Wood.ID", 5); }
public int getRepairDiamondMaterial() { return config.getInt("Skills.Repair.Diamond.ID", 264); }
public int getRepairIronMaterial() { return config.getInt("Skills.Repair.Iron.ID", 265); }
public int getRepairStringMaterial() { return config.getInt("Skills.Repair.String.ID", 287); }
public int getRepairLeatherMaterial() { return config.getInt("Skills.Repair.Leather.ID", 334); }
public boolean getRepairArmorAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Armor", true); }
public boolean getRepairToolsAllowed() { return config.getBoolean("Skills.Repair.Can_Repair_Tools", true); }
public int getRepairDiamondLevelRequirement() { return config.getInt("Skills.Repair.Diamond.Level_Required", 50); }
public int getRepairIronLevelRequirement() { return config.getInt("Skills.Repair.Iron.Level_Required", 0); }
public int getRepairGoldLevelRequirement() { return config.getInt("Skills.Repair.Gold.Level_Required", 0); }
public int getRepairStoneLevelRequirement() { return config.getInt("Skills.Repair.Stone.Level_Required", 0); }
public int getRepairStringLevelRequirement() { return config.getInt("Skills.Repair.String.Level_Required", 0); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
@@ -185,6 +260,30 @@ public class Config extends ConfigLoader {
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
public boolean woodcuttingDoubleDropsDisabled() {
ConfigurationSection section = config.getConfigurationSection("Double_Drops.Woodcutting");
Set<String> keys = section.getKeys(false);
Iterator<String> iterator = keys.iterator();
boolean disabled = true;
while (iterator.hasNext()) {
String key = iterator.next();
if (config.getBoolean("Double_Drops.Woodcutting." + key)) {
disabled = false;
break;
}
}
return disabled;
}
/* Arcane Forging */
public boolean getArcaneForgingDowngradeEnabled() { return config.getBoolean("Arcane_Forging.Downgrades.Enabled", true); }
public int getArcaneForgingDowngradeChanceRank1() { return config.getInt("Arcane_Forging.Downgrades.Chance.Rank_1", 75); }
@@ -216,6 +315,20 @@ public class Config extends ConfigLoader {
public int getLevelCapWoodcutting() { return config.getInt("Skills.Woodcutting.Level_Cap", 0); }
public int getPowerLevelCap() { return config.getInt("General.Power_Level_Cap", 0); }
/* PVP & PVE Settings */
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
public boolean getAcrobaticsPVE() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVE", true); }
public boolean getArcheryPVP() { return config.getBoolean("Skills.Archery.Enabled_For_PVP", true); }
public boolean getArcheryPVE() { return config.getBoolean("Skills.Archery.Enabled_For_PVE", true); }
public boolean getAxesPVP() { return config.getBoolean("Skills.Axes.Enabled_For_PVP", true); }
public boolean getAxesPVE() { return config.getBoolean("Skills.Axes.Enabled_For_PVE", true); }
public boolean getSwordsPVP() { return config.getBoolean("Skills.Swords.Enabled_For_PVP", true); }
public boolean getSwordsPVE() { return config.getBoolean("Skills.Swords.Enabled_For_PVE", true); }
public boolean getTamingPVP() { return config.getBoolean("Skills.Taming.Enabled_For_PVP", true); }
public boolean getTamingPVE() { return config.getBoolean("Skills.Taming.Enabled_For_PVE", true); }
public boolean getUnarmedPVP() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVP", true); }
public boolean getUnarmedPVE() { return config.getBoolean("Skills.Unarmed.Enabled_For_PVE", true); }
/*
* XP SETTINGS
*/
@@ -227,7 +340,6 @@ public class Config extends ConfigLoader {
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getCreeperXP() { return config.getDouble("Experience.Combat.Multiplier.Creeper", 4.0); }
public double getSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Skeleton", 2.0); }
@@ -245,6 +357,7 @@ public class Config extends ConfigLoader {
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getFormulaMultiplierTaming() { return config.getDouble("Experience.Formula.Multiplier.Taming", 1.0); }
public double getFormulaMultiplierMining() { return config.getDouble("Experience.Formula.Multiplier.Mining", 1.0); }
public double getFormulaMultiplierRepair() { return config.getDouble("Experience.Formula.Multiplier.Repair", 1.0); }
@@ -258,105 +371,18 @@ public class Config extends ConfigLoader {
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
/*
* SPOUT SETTINGS
*/
public boolean spoutEnabled;
public boolean getShowPowerLevelForSpout() { return config.getBoolean("Spout.HUD.Show_Power_Level", true); }
/* Spout XP Bar */
public boolean getSpoutXPBarEnabled() { return config.getBoolean("Spout.XP.Bar.Enabled", true); }
public boolean getSpoutXPBarIconEnabled() { return config.getBoolean("Spout.XP.Icon.Enabled", true); }
public int getSpoutXPBarXPosition() { return config.getInt("Spout.XP.Bar.X_POS", 95); }
public int getSpoutXPBarYPosition() { return config.getInt("Spout.XP.Bar.Y_POS", 6); }
public int getSpoutXPIconXPosition() { return config.getInt("Spout.XP.Icon.X_POS", 78); }
public int getSpoutXPIconYPosition() { return config.getInt("Spout.XP.Icon.Y_POS", 2); }
/* Spout HUD Colors */
public double getSpoutRetroHUDXPBorderRed() { return config.getDouble("Spout.HUD.Retro.Colors.Border.RED", 0.0); }
public double getSpoutRetroHUDXPBorderGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Border.GREEN", 0.0); }
public double getSpoutRetroHUDXPBorderBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Border.BLUE", 0.0); }
public double getSpoutRetroHUDXPBackgroundRed() { return config.getDouble("Spout.HUD.Retro.Colors.Background.RED", 0.75); }
public double getSpoutRetroHUDXPBackgroundGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Background.GREEN", 0.75); }
public double getSpoutRetroHUDXPBackgroundBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Background.BLUE", 0.75); }
public double getSpoutRetroHUDAcrobaticsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.RED", 0.3); }
public double getSpoutRetroHUDAcrobaticsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.GREEN", 0.3); }
public double getSpoutRetroHUDAcrobaticsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Acrobatics.BLUE", 0.75); }
public double getSpoutRetroHUDArcheryRed() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.RED", 0.3); }
public double getSpoutRetroHUDArcheryGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.GREEN", 0.3); }
public double getSpoutRetroHUDArcheryBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Archery.BLUE", 0.75); }
public double getSpoutRetroHUDAxesRed() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.RED", 0.3); }
public double getSpoutRetroHUDAxesGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.GREEN", 0.3); }
public double getSpoutRetroHUDAxesBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Axes.BLUE", 0.75); }
public double getSpoutRetroHUDExcavationRed() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.RED", 0.3); }
public double getSpoutRetroHUDExcavationGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.GREEN", 0.3); }
public double getSpoutRetroHUDExcavationBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Excavation.BLUE", 0.75); }
public double getSpoutRetroHUDHerbalismRed() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.RED", 0.3); }
public double getSpoutRetroHUDHerbalismGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.GREEN", 0.3); }
public double getSpoutRetroHUDHerbalismBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Herbalism.BLUE", 0.75); }
public double getSpoutRetroHUDMiningRed() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.RED", 0.3); }
public double getSpoutRetroHUDMiningGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.GREEN", 0.3); }
public double getSpoutRetroHUDMiningBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Mining.BLUE", 0.75); }
public double getSpoutRetroHUDRepairRed() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.RED", 0.3); }
public double getSpoutRetroHUDRepairGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.GREEN", 0.3); }
public double getSpoutRetroHUDRepairBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Repair.BLUE", 0.75); }
public double getSpoutRetroHUDSwordsRed() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.RED", 0.3); }
public double getSpoutRetroHUDSwordsGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.GREEN", 0.3); }
public double getSpoutRetroHUDSwordsBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Swords.BLUE", 0.75); }
public double getSpoutRetroHUDTamingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.RED", 0.3); }
public double getSpoutRetroHUDTamingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.GREEN", 0.3); }
public double getSpoutRetroHUDTamingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Taming.BLUE", 0.75); }
public double getSpoutRetroHUDUnarmedRed() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.RED", 0.3); }
public double getSpoutRetroHUDUnarmedGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.GREEN", 0.3); }
public double getSpoutRetroHUDUnarmedBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Unarmed.BLUE", 0.75); }
public double getSpoutRetroHUDWoodcuttingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.RED", 0.3); }
public double getSpoutRetroHUDWoodcuttingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.GREEN", 0.3); }
public double getSpoutRetroHUDWoodcuttingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Woodcutting.BLUE", 0.75); }
public double getSpoutRetroHUDFishingRed() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.RED", 0.3); }
public double getSpoutRetroHUDFishingGreen() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.GREEN", 0.3); }
public double getSpoutRetroHUDFishingBlue() { return config.getDouble("Spout.HUD.Retro.Colors.Fishing.BLUE", 0.75); }
/*
* CONFIG LOADING
*/
public HUDType defaulthud;
private Config(mcMMO plugin) {
super(plugin, "config.yml");
config = plugin.getConfig();
saveIfNotExist();
xpGainMultiplier = getExperienceGainsGlobalMultiplier();
load();
}
@Override
protected void load() {
// If it doesn't exist, copy it from the .jar
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveDefaultConfig();
}
addDefaults();
loadKeys();
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO config.yml File...");
// Setup default HUD
String temp = config.getString("Spout.HUD.Default", "STANDARD");
for (HUDType x : HUDType.values()) {
if (x.toString().toLowerCase().equalsIgnoreCase(temp.toString().toLowerCase())) {
defaulthud = x;
}
}
if(defaulthud == null)
defaulthud = HUDType.STANDARD;
}
}
}

View File

@@ -4,11 +4,12 @@ import java.io.File;
import java.io.IOException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
public abstract class ConfigLoader {
protected String fileName;
protected File configFile;
protected File dataFolder;
protected final mcMMO plugin;
@@ -16,14 +17,24 @@ public abstract class ConfigLoader {
public ConfigLoader(mcMMO plugin, String fileName){
this.plugin = plugin;
this.fileName = fileName;
dataFolder = plugin.getDataFolder();
configFile = new File(dataFolder, File.separator + fileName);
config = YamlConfiguration.loadConfiguration(configFile);
}
/**
* Load this config file.
*/
protected abstract void load();
public void load() {
if (!configFile.exists()) {
dataFolder.mkdir();
saveConfig();
}
addDefaults();
loadKeys();
}
/**
* Save this config file.
@@ -32,17 +43,28 @@ public abstract class ConfigLoader {
try {
config.save(configFile);
}
catch (IOException e) {
e.printStackTrace();
catch (IOException ex) {
plugin.getLogger().severe("Could not save config to " + configFile + ex);
}
}
protected void saveIfNotExist() {
if (!configFile.exists()) {
if (plugin.getResource(fileName) != null) {
plugin.saveResource(fileName, false);
}
}
rereadFromDisk();
}
protected void rereadFromDisk() {
config = YamlConfiguration.loadConfiguration(configFile);
}
/**
* Add the defaults to this config file.
*/
protected void addDefaults() {
// Load from included config.yml
config.options().copyDefaults(true);
saveConfig();
}

View File

@@ -0,0 +1,46 @@
package com.gmail.nossr50.config;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
public class HiddenConfig extends ConfigLoader {
private static String fileName;
private static HiddenConfig instance;
private static YamlConfiguration config;
private static boolean chunkletsEnabled;
public HiddenConfig(mcMMO plugin, String fileName) {
super(plugin, fileName);
HiddenConfig.fileName = fileName;
}
public static HiddenConfig getInstance() {
if (instance == null) {
instance = new HiddenConfig(mcMMO.p, "hidden.yml");
instance.load();
}
return instance;
}
@Override
public void load() {
if (plugin.getResource(fileName) != null) {
loadKeys();
}
}
@Override
protected void loadKeys() {
config = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
}
public boolean getChunkletsEnabled() {
return chunkletsEnabled;
}
}

View File

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

View File

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

View File

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

View File

@@ -16,12 +16,13 @@ import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.Treasure;
public class LoadTreasures extends ConfigLoader{
private static LoadTreasures instance;
public class TreasuresConfig extends ConfigLoader{
private static TreasuresConfig instance;
public static LoadTreasures getInstance() {
public static TreasuresConfig getInstance() {
if (instance == null) {
instance = new LoadTreasures(mcMMO.p);
instance = new TreasuresConfig(mcMMO.p);
instance.load();
}
return instance;
@@ -40,23 +41,9 @@ public class LoadTreasures extends ConfigLoader{
public List<FishingTreasure> fishingRewardsTier4 = new ArrayList<FishingTreasure>();
public List<FishingTreasure> fishingRewardsTier5 = new ArrayList<FishingTreasure>();
private LoadTreasures(mcMMO plugin) {
private TreasuresConfig(mcMMO plugin) {
super(plugin, "treasures.yml");
config = plugin.getTreasuresConfig();
load();
}
@Override
protected void load() {
// If it doesn't exist, copy it from the .jar
if (!configFile.exists()) {
dataFolder.mkdir();
plugin.saveTreasuresConfig();
}
addDefaults();
loadKeys();
saveIfNotExist();
}
@Override
@@ -95,7 +82,7 @@ public class LoadTreasures extends ConfigLoader{
int data = config.getInt("Treasures." + treasureName + ".Data");
if (Material.getMaterial(id) == null) {
reason.add("Invlid id: " + id);
reason.add("Invalid id: " + id);
}
if (amount < 1) {

View File

@@ -0,0 +1,97 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomItem;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomArmorConfig extends ModConfigLoader{
private static CustomArmorConfig instance;
public static CustomArmorConfig getInstance() {
if (instance == null) {
instance = new CustomArmorConfig(mcMMO.p);
}
return instance;
}
private List<Repairable> repairables;
public List<Integer> customBootIDs = new ArrayList<Integer>();
public List<Integer> customChestplateIDs = new ArrayList<Integer>();
public List<Integer> customHelmetIDs = new ArrayList<Integer>();
public List<Integer> customLeggingIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomItem> customArmorList = new ArrayList<CustomItem>();
public HashMap<Integer, CustomItem> customArmor = new HashMap<Integer, CustomItem>();
public CustomArmorConfig(mcMMO plugin) {
super(plugin, "armor.yml");
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO armor.yml File...");
repairables = new ArrayList<Repairable>();
loadArmor("Boots", customBootIDs);
loadArmor("Chestplates", customChestplateIDs);
loadArmor("Helmets", customHelmetIDs);
loadArmor("Leggings", customLeggingIDs);
}
private void loadArmor(String armorType, List<Integer> idList) {
ConfigurationSection armorSection = config.getConfigurationSection(armorType);
Set<String> armorConfigSet = armorSection.getKeys(false);
Iterator<String> iterator = armorConfigSet.iterator();
while (iterator.hasNext()) {
String armorName = iterator.next();
int id = config.getInt(armorType + "." + armorName + ".ID", 0);
boolean repairable = config.getBoolean(armorType + "." + armorName + ".Repairable");
int repairID = config.getInt(armorType + "." + armorName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(armorType + "." + armorName + ".Repair_Material_Data_Value", 0);
int repairQuantity = config.getInt(armorType + "." + armorName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(armorType + "." + armorName + ".Durability", 0);
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
repairable = false;
}
CustomItem armor;
if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
armor = new CustomItem(id, durability);
idList.add(id);
customIDs.add(id);
customArmorList.add(armor);
customArmor.put(id, armor);
}
}
public List<Repairable> getLoadedRepairables() {
if(repairables == null) return new ArrayList<Repairable>();
return repairables;
}
}

View File

@@ -0,0 +1,110 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlocksConfig extends ModConfigLoader{
private static CustomBlocksConfig instance;
public static CustomBlocksConfig getInstance() {
if (instance == null) {
instance = new CustomBlocksConfig(mcMMO.p);
}
return instance;
}
public List<ItemStack> customExcavationBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customHerbalismBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customMiningBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customWoodcuttingBlocks = new ArrayList<ItemStack>();
public List<ItemStack> customOres = new ArrayList<ItemStack>();
public List<ItemStack> customLogs = new ArrayList<ItemStack>();
public List<ItemStack> customLeaves = new ArrayList<ItemStack>();
public List<ItemStack> customItems = new ArrayList<ItemStack>();
public List<CustomBlock> customBlocks = new ArrayList<CustomBlock>();
public CustomBlocksConfig(mcMMO plugin) {
super(plugin, "blocks.yml");
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO blocks.yml File...");
loadBlocks("Excavation", customExcavationBlocks);
loadBlocks("Herbalism", customHerbalismBlocks);
loadBlocks("Mining", customMiningBlocks);
loadBlocks("Woodcutting", customWoodcuttingBlocks);
}
private void loadBlocks(String skillType, List<ItemStack> blockList) {
ConfigurationSection skillSection = config.getConfigurationSection(skillType);
Set<String> skillConfigSet = skillSection.getKeys(false);
Iterator<String> iterator = skillConfigSet.iterator();
while (iterator.hasNext()) {
String blockName = iterator.next();
int id = config.getInt(skillType + "." + blockName + ".ID", 0);
byte data = (byte) config.getInt(skillType + "." + blockName + ".Data_Value", 0);
int xp = config.getInt(skillType + "." + blockName + ".XP_Gain", 0);
int tier = config.getInt(skillType + "." + blockName + ".Tier", 1);
boolean dropItem = config.getBoolean(skillType + "." + blockName + ".Drop_Item", false);
int dropID = config.getInt(skillType + "." + blockName + ".Drop_Item_ID", 0);
byte dropData = (byte) config.getInt(skillType + "." + blockName + ".Drop_Item_Data_Value", 0);
int dropAmount = config.getInt(skillType + "." + blockName + ".Drop_Item_Amount", 1);
if (id == 0) {
plugin.getLogger().warning("Missing ID. This block will be skipped.");
continue;
}
if (dropItem && dropID == 0) {
plugin.getLogger().warning("Incomplete item drop information. This block will drop itself.");
dropItem = false;
}
CustomBlock block;
ItemStack itemDrop;
ItemStack blockItem;
if (dropItem) {
itemDrop = new ItemStack(dropID, dropAmount, (short) 0, dropData);
}
else {
itemDrop = new ItemStack(id, dropAmount, (short) 0, data);
}
block = new CustomBlock(itemDrop, tier, xp, data, id);
blockItem = new ItemStack(id, 1, (short) 0, data);
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockItem);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockItem);
}
else {
customLeaves.add(blockItem);
block.setXpGain(0); //Leaves don't grant XP
}
}
blockList.add(blockItem);
customItems.add(blockItem);
customBlocks.add(block);
}
}
}

View File

@@ -0,0 +1,104 @@
package com.gmail.nossr50.config.mods;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import org.bukkit.configuration.ConfigurationSection;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.skills.repair.RepairableFactory;
public class CustomToolsConfig extends ModConfigLoader {
private static CustomToolsConfig instance;
public static CustomToolsConfig getInstance() {
if (instance == null) {
instance = new CustomToolsConfig(mcMMO.p);
}
return instance;
}
private List<Repairable> repairables;
public List<Integer> customAxeIDs = new ArrayList<Integer>();
public List<Integer> customBowIDs = new ArrayList<Integer>();
public List<Integer> customHoeIDs = new ArrayList<Integer>();
public List<Integer> customPickaxeIDs = new ArrayList<Integer>();
public List<Integer> customShovelIDs = new ArrayList<Integer>();
public List<Integer> customSwordIDs = new ArrayList<Integer>();
public List<Integer> customIDs = new ArrayList<Integer>();
public List<CustomTool> customToolList = new ArrayList<CustomTool>();
public HashMap<Integer, CustomTool> customTools = new HashMap<Integer, CustomTool>();
private CustomToolsConfig(mcMMO plugin) {
super(plugin, "tools.yml");
}
@Override
protected void loadKeys() {
plugin.getLogger().info("Loading mcMMO tools.yml File...");
repairables = new ArrayList<Repairable>();
loadTool("Axes", customAxeIDs);
loadTool("Bows", customBowIDs);
loadTool("Hoes", customHoeIDs);
loadTool("Pickaxes", customPickaxeIDs);
loadTool("Shovels", customShovelIDs);
loadTool("Swords", customSwordIDs);
}
private void loadTool(String toolType, List<Integer> idList) {
ConfigurationSection toolSection = config.getConfigurationSection(toolType);
Set<String> toolConfigSet = toolSection.getKeys(false);
Iterator<String> iterator = toolConfigSet.iterator();
while (iterator.hasNext()) {
String toolName = iterator.next();
int id = config.getInt(toolType + "." + toolName + ".ID", 0);
double multiplier = config.getDouble(toolType + "." + toolName + ".XP_Modifier", 1.0);
boolean abilityEnabled = config.getBoolean(toolType + "." + toolName + ".Ability_Enabled", true);
int tier = config.getInt(toolType + "." + toolName + ".Tier", 1);
boolean repairable = config.getBoolean(toolType + "." + toolName + ".Repairable");
int repairID = config.getInt(toolType + "." + toolName + ".Repair_Material_ID", 0);
byte repairData = (byte) config.getInt(toolType + "." + toolName + ".Repair_Material_Data_Value", 0);
int repairQuantity = config.getInt(toolType + "." + toolName + ".Repair_Material_Quantity", 0);
short durability = (short) config.getInt(toolType + "." + toolName + ".Durability", 0);
if (id == 0) {
plugin.getLogger().warning("Missing ID. This item will be skipped.");
continue;
}
if (repairable && (repairID == 0 || repairQuantity == 0 || durability == 0)) {
plugin.getLogger().warning("Incomplete repair information. This item will be unrepairable.");
repairable = false;
}
CustomTool tool;
if (repairable) {
repairables.add(RepairableFactory.getRepairable(id, repairID, repairData, repairQuantity, durability));
}
tool = new CustomTool(tier, abilityEnabled, multiplier, durability, id);
idList.add(id);
customIDs.add(id);
customToolList.add(tool);
customTools.put(id, tool);
}
}
public List<Repairable> getLoadedRepairables() {
if(repairables == null) return new ArrayList<Repairable>();
return repairables;
}
}

View File

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

View File

@@ -1,18 +1,18 @@
package com.gmail.nossr50.datatypes;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Permissions;
public enum AbilityType {
BERSERK(
Config.getInstance().getAbilityCooldownBerserk(),
Config.getInstance().getAbilityMaxTicksBerserk(),
"Unarmed.Skills.Berserk.On",
"Unarmed.Skills.Berserk.Off",
"Unarmed.Skills.Berserk.Other.On",
@@ -21,6 +21,7 @@ public enum AbilityType {
SUPER_BREAKER(
Config.getInstance().getAbilityCooldownSuperBreaker(),
Config.getInstance().getAbilityMaxTicksSuperBreaker(),
"Mining.Skills.SuperBreaker.On",
"Mining.Skills.SuperBreaker.Off",
"Mining.Skills.SuperBreaker.Other.On",
@@ -29,6 +30,7 @@ public enum AbilityType {
GIGA_DRILL_BREAKER(
Config.getInstance().getAbilityCooldownGigaDrillBreaker(),
Config.getInstance().getAbilityMaxTicksGigaDrillBreaker(),
"Excavation.Skills.GigaDrillBreaker.On",
"Excavation.Skills.GigaDrillBreaker.Off",
"Excavation.Skills.GigaDrillBreaker.Other.On",
@@ -37,6 +39,7 @@ public enum AbilityType {
GREEN_TERRA(
Config.getInstance().getAbilityCooldownGreenTerra(),
Config.getInstance().getAbilityMaxTicksGreenTerra(),
"Herbalism.Skills.GTe.On",
"Herbalism.Skills.GTe.Off",
"Herbalism.Skills.GTe.Other.On",
@@ -45,6 +48,7 @@ public enum AbilityType {
SKULL_SPLIITER(
Config.getInstance().getAbilityCooldownSkullSplitter(),
Config.getInstance().getAbilityMaxTicksSkullSplitter(),
"Axes.Skills.SS.On",
"Axes.Skills.SS.Off",
"Axes.Skills.SS.Other.On",
@@ -53,6 +57,7 @@ public enum AbilityType {
TREE_FELLER(
Config.getInstance().getAbilityCooldownTreeFeller(),
Config.getInstance().getAbilityMaxTicksTreeFeller(),
"Woodcutting.Skills.TreeFeller.On",
"Woodcutting.Skills.TreeFeller.Off",
"Woodcutting.Skills.TreeFeller.Other.On",
@@ -61,6 +66,7 @@ public enum AbilityType {
SERRATED_STRIKES(
Config.getInstance().getAbilityCooldownSerratedStrikes(),
Config.getInstance().getAbilityMaxTicksSerratedStrikes(),
"Swords.Skills.SS.On",
"Swords.Skills.SS.Off",
"Swords.Skills.SS.Other.On",
@@ -69,6 +75,7 @@ public enum AbilityType {
BLAST_MINING(
Config.getInstance().getAbilityCooldownBlastMining(),
Config.getInstance().getAbilityMaxTicksBlastMining(),
null,
null,
"Mining.Blast.Other.On",
@@ -76,6 +83,7 @@ public enum AbilityType {
null),
LEAF_BLOWER(
0,
0,
null,
null,
@@ -84,14 +92,16 @@ public enum AbilityType {
null);
private int cooldown;
private int maxTicks;
private String abilityOn;
private String abilityOff;
private String abilityPlayer;
private String abilityRefresh;
private String abilityPlayerOff;
private AbilityType(int cooldown, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
private AbilityType(int cooldown, int maxTicks, String abilityOn, String abilityOff, String abilityPlayer, String abilityRefresh, String abilityPlayerOff) {
this.cooldown = cooldown;
this.maxTicks = maxTicks;
this.abilityOn = abilityOn;
this.abilityOff = abilityOff;
this.abilityPlayer = abilityPlayer;
@@ -123,6 +133,10 @@ public enum AbilityType {
return LocaleLoader.getString(this.abilityRefresh);
}
public int getMaxTicks() {
return this.maxTicks;
}
/**
* Get the permissions for this ability.
*
@@ -130,33 +144,35 @@ public enum AbilityType {
* @return true if the player has permissions, false otherwise
*/
public boolean getPermissions(Player player) {
Permissions permInstance = Permissions.getInstance();
switch (this) {
case BERSERK:
return Permissions.getInstance().berserk(player);
return permInstance.berserk(player);
case BLAST_MINING:
return Permissions.getInstance().blastMining(player);
return permInstance.blastMining(player);
case GIGA_DRILL_BREAKER:
return Permissions.getInstance().gigaDrillBreaker(player);
return permInstance.gigaDrillBreaker(player);
case GREEN_TERRA:
return Permissions.getInstance().greenTerra(player);
return permInstance.greenTerra(player);
case LEAF_BLOWER:
return Permissions.getInstance().leafBlower(player);
return permInstance.leafBlower(player);
case SERRATED_STRIKES:
return Permissions.getInstance().serratedStrikes(player);
return permInstance.serratedStrikes(player);
case SKULL_SPLIITER:
return Permissions.getInstance().skullSplitter(player);
return permInstance.skullSplitter(player);
case SUPER_BREAKER:
return Permissions.getInstance().superBreaker(player);
return permInstance.superBreaker(player);
case TREE_FELLER:
return Permissions.getInstance().treeFeller(player);
return permInstance.treeFeller(player);
default:
return false;
@@ -166,28 +182,28 @@ public enum AbilityType {
/**
* Check if a block is affected by this ability.
*
* @param material The block type to check
* @param Block the block to check
* @return true if the block is affected by this ability, false otherwise
*/
public boolean blockCheck(Material material) {
public boolean blockCheck(Block block) {
switch (this) {
case BERSERK:
return (Excavation.canBeGigaDrillBroken(material) || material.equals(Material.SNOW));
return (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW);
case GIGA_DRILL_BREAKER:
return Excavation.canBeGigaDrillBroken(material);
return BlockChecks.canBeGigaDrillBroken(block);
case GREEN_TERRA:
return Herbalism.makeMossy(material);
return BlockChecks.makeMossy(block);
case LEAF_BLOWER:
return material.equals(Material.LEAVES);
return block.getType() == Material.LEAVES;
case SUPER_BREAKER:
return Mining.canBeSuperBroken(material);
return BlockChecks.canBeSuperBroken(block);
case TREE_FELLER:
return material.equals(Material.LOG);
return block.getType() == Material.LOG;
default:
return false;

View File

@@ -10,7 +10,7 @@ import org.getspout.spoutapi.gui.Widget;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
@@ -119,9 +119,9 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplayRetro(SpoutPlayer sPlayer) {
Color border = new Color((float) Config.getInstance().getSpoutRetroHUDXPBorderRed(), (float) Config.getInstance().getSpoutRetroHUDXPBorderGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBorderBlue(), 1f);
Color 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) Config.getInstance().getSpoutRetroHUDXPBackgroundRed(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundGreen(), (float) Config.getInstance().getSpoutRetroHUDXPBackgroundBlue(), 1f);
Color background = new Color((float) SpoutConfig.getInstance().getRetroHUDXPBackgroundRed(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundGreen(), (float) SpoutConfig.getInstance().getRetroHUDXPBackgroundBlue(), 1f);
Color darkbg = new Color(0.2f, 0.2f, 0.2f, 1f);
xpicon = new GenericTexture();
@@ -185,12 +185,12 @@ public class HUDmmo {
xpbg.setPriority(RenderPriority.Low);
xpbg.setDirty(true);
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
sPlayer.getMainScreen().attachWidget(plugin, xpfill);
sPlayer.getMainScreen().attachWidget(plugin, xpbg);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_bg);
sPlayer.getMainScreen().attachWidget(plugin, xpicon_border);
@@ -206,26 +206,28 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
public void initializeXpBarDisplayStandard(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture) xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(Config.getInstance().getSpoutXPBarXPosition());
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setX(SpoutConfig.getInstance().getXPBarXPosition());
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(8);
xpbar.setWidth(256);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(16);
xpicon.setWidth(32);
xpicon.setX(Config.getInstance().getSpoutXPIconXPosition());
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition());
xpicon.setX(SpoutConfig.getInstance().getXPIconXPosition());
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition());
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
@@ -241,25 +243,27 @@ public class HUDmmo {
* @param sPlayer Player to initialize XP bar for
*/
private void initializeXpBarDisplaySmall(SpoutPlayer sPlayer) {
if (Config.getInstance().getSpoutXPBarEnabled()) {
if (SpoutConfig.getInstance().getXPBarEnabled()) {
xpbar = new GenericTexture();
((GenericTexture)xpbar).setUrl("xpbar_inc000.png");
xpbar.setX(center_x - 64);
xpbar.setY(Config.getInstance().getSpoutXPBarYPosition());
xpbar.setY(SpoutConfig.getInstance().getXPBarYPosition());
xpbar.setHeight(4);
xpbar.setWidth(128);
xpbar.setPriority(RenderPriority.Lowest);
sPlayer.getMainScreen().attachWidget(plugin, xpbar);
if (Config.getInstance().getSpoutXPBarIconEnabled()) {
if (SpoutConfig.getInstance().getXPBarIconEnabled()) {
xpicon = new GenericTexture();
xpicon.setUrl("Icon.png");
xpicon.setHeight(8);
xpicon.setWidth(16);
xpicon.setX(center_x - (8 + 64));
xpicon.setY(Config.getInstance().getSpoutXPIconYPosition() + 2);
xpicon.setY(SpoutConfig.getInstance().getXPIconYPosition() + 2);
xpicon.setPriority(RenderPriority.High);
xpicon.setDirty(true);
sPlayer.getMainScreen().attachWidget(plugin, xpicon);
@@ -276,7 +280,7 @@ public class HUDmmo {
* @param PP Profile of the given player
*/
private void updateXpBarStandard(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
@@ -286,7 +290,7 @@ public class HUDmmo {
return;
}
((GenericTexture) xpicon).setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setUrl(Misc.getCapitalized(theType.toString()) + ".png");
xpicon.setDirty(true);
((GenericTexture) xpbar).setUrl(getUrlBar(getXpInc(PP.getSkillXpLevel(theType), PP.getXpToLevel(theType), HUDType.STANDARD)));
@@ -302,7 +306,7 @@ public class HUDmmo {
* @param PP Profile of the given player
*/
private void updateXpBarRetro(Player player, PlayerProfile PP) {
if (!Config.getInstance().getSpoutXPBarEnabled()) {
if (!SpoutConfig.getInstance().getXPBarEnabled()) {
return;
}
@@ -327,40 +331,40 @@ public class HUDmmo {
private static Color getRetroColor(SkillType type) {
switch (type) {
case ACROBATICS:
return new Color((float) Config.getInstance().getSpoutRetroHUDAcrobaticsRed(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsGreen(), (float) Config.getInstance().getSpoutRetroHUDAcrobaticsBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDAcrobaticsRed(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsGreen(), (float) SpoutConfig.getInstance().getRetroHUDAcrobaticsBlue(), 1f);
case ARCHERY:
return new Color((float) Config.getInstance().getSpoutRetroHUDArcheryRed(), (float) Config.getInstance().getSpoutRetroHUDArcheryGreen(), (float) Config.getInstance().getSpoutRetroHUDArcheryBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDArcheryRed(), (float) SpoutConfig.getInstance().getRetroHUDArcheryGreen(), (float) SpoutConfig.getInstance().getRetroHUDArcheryBlue(), 1f);
case AXES:
return new Color((float) Config.getInstance().getSpoutRetroHUDAxesRed(), (float) Config.getInstance().getSpoutRetroHUDAxesGreen(), (float) Config.getInstance().getSpoutRetroHUDAxesBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDAxesRed(), (float) SpoutConfig.getInstance().getRetroHUDAxesGreen(), (float) SpoutConfig.getInstance().getRetroHUDAxesBlue(), 1f);
case EXCAVATION:
return new Color((float) Config.getInstance().getSpoutRetroHUDExcavationRed(), (float) Config.getInstance().getSpoutRetroHUDExcavationGreen(), (float) Config.getInstance().getSpoutRetroHUDExcavationBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDExcavationRed(), (float) SpoutConfig.getInstance().getRetroHUDExcavationGreen(), (float) SpoutConfig.getInstance().getRetroHUDExcavationBlue(), 1f);
case HERBALISM:
return new Color((float) Config.getInstance().getSpoutRetroHUDHerbalismRed(), (float) Config.getInstance().getSpoutRetroHUDHerbalismGreen(), (float) Config.getInstance().getSpoutRetroHUDHerbalismBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDHerbalismRed(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismGreen(), (float) SpoutConfig.getInstance().getRetroHUDHerbalismBlue(), 1f);
case MINING:
return new Color((float) Config.getInstance().getSpoutRetroHUDMiningRed(), (float) Config.getInstance().getSpoutRetroHUDMiningGreen(), (float) Config.getInstance().getSpoutRetroHUDMiningBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDMiningRed(), (float) SpoutConfig.getInstance().getRetroHUDMiningGreen(), (float) SpoutConfig.getInstance().getRetroHUDMiningBlue(), 1f);
case REPAIR:
return new Color((float) Config.getInstance().getSpoutRetroHUDRepairRed(), (float) Config.getInstance().getSpoutRetroHUDRepairGreen(), (float) Config.getInstance().getSpoutRetroHUDRepairBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDRepairRed(), (float) SpoutConfig.getInstance().getRetroHUDRepairGreen(), (float) SpoutConfig.getInstance().getRetroHUDRepairBlue(), 1f);
case SWORDS:
return new Color((float) Config.getInstance().getSpoutRetroHUDSwordsRed(), (float) Config.getInstance().getSpoutRetroHUDSwordsGreen(), (float) Config.getInstance().getSpoutRetroHUDSwordsBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDSwordsRed(), (float) SpoutConfig.getInstance().getRetroHUDSwordsGreen(), (float) SpoutConfig.getInstance().getRetroHUDSwordsBlue(), 1f);
case TAMING:
return new Color((float) Config.getInstance().getSpoutRetroHUDTamingRed(), (float) Config.getInstance().getSpoutRetroHUDTamingGreen(), (float) Config.getInstance().getSpoutRetroHUDTamingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDTamingRed(), (float) SpoutConfig.getInstance().getRetroHUDTamingGreen(), (float) SpoutConfig.getInstance().getRetroHUDTamingBlue(), 1f);
case UNARMED:
return new Color((float) Config.getInstance().getSpoutRetroHUDUnarmedRed(), (float) Config.getInstance().getSpoutRetroHUDUnarmedGreen(), (float) Config.getInstance().getSpoutRetroHUDUnarmedBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDUnarmedRed(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedGreen(), (float) SpoutConfig.getInstance().getRetroHUDUnarmedBlue(), 1f);
case WOODCUTTING:
return new Color((float) Config.getInstance().getSpoutRetroHUDWoodcuttingRed(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingGreen(), (float) Config.getInstance().getSpoutRetroHUDWoodcuttingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDWoodcuttingRed(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingGreen(), (float) SpoutConfig.getInstance().getRetroHUDWoodcuttingBlue(), 1f);
case FISHING:
return new Color((float) Config.getInstance().getSpoutRetroHUDFishingRed(), (float) Config.getInstance().getSpoutRetroHUDFishingGreen(), (float) Config.getInstance().getSpoutRetroHUDFishingBlue(), 1f);
return new Color((float) SpoutConfig.getInstance().getRetroHUDFishingRed(), (float) SpoutConfig.getInstance().getRetroHUDFishingGreen(), (float) SpoutConfig.getInstance().getRetroHUDFishingBlue(), 1f);
default:
return new Color(0.3f, 0.3f, 0.75f, 1f);

View File

@@ -4,64 +4,71 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.mcMMO;
public class PlayerProfile {
/* HUD */
private HUDType hud;
private int xpbarinc = 0;
private int xpbarinc;
private SkillType lastgained;
private SkillType skillLock;
/* Party Stuff */
private String party;
private String invite;
private Party party;
private Party invite;
/* Toggles */
private boolean loaded = false;
private boolean partyhud = true, spoutcraft = false, xpbarlocked = false;
private boolean placedAnvil = false;
private boolean partyChatMode = false, adminChatMode = false;
private boolean godMode = false;
private boolean loaded;
private boolean partyhud = true, spoutcraft, xpbarlocked;
private boolean placedAnvil;
private boolean partyChatMode, adminChatMode;
private boolean godMode;
private boolean greenTerraMode, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, serratedStrikesMode, skullSplitterMode, berserkMode;
private boolean greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, blastMiningInformed = true, serratedStrikesInformed = true, treeFellerInformed = true;
private boolean hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false,
pickaxePreparationMode = false, axePreparationMode = false;
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
pickaxePreparationMode, axePreparationMode;
private boolean abilityuse = true;
/* Timestamps */
private int xpGainATS = 0;
private int recentlyHurt = 0;
private int recentlyHurt;
private int respawnATS;
/* mySQL STUFF */
private int lastlogin = 0;
private int userid = 0;
private int userid;
HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and Levels
HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>();
HashMap<ToolType, Integer> toolATS = new HashMap<ToolType, Integer>();
private Player player;
private String playerName;
private String location = mcMMO.usersFile;
private final static String location = mcMMO.usersFile;
public PlayerProfile(String name, boolean addNew) {
hud = Config.getInstance().defaulthud;
playerName = name;
public PlayerProfile(Player player, String playerName, boolean addNew) {
hud = SpoutConfig.getInstance().defaulthud;
this.player = player;
this.playerName = playerName;
party = PartyManager.getInstance().getPlayerParty(playerName);
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
@@ -77,63 +84,63 @@ public class PlayerProfile {
if (Config.getInstance().getUseMySQL()) {
if (!loadMySQL() && addNew) {
addMySQLPlayer();
loaded = true;
}
}
else if (!load() && addNew) {
addPlayer();
loaded = true;
}
lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue();
}
public String getPlayerName() {
return this.playerName;
}
public Player getPlayer() {
return mcMMO.p.getServer().getPlayer(playerName);
return player;
}
public String getPlayerName() {
return playerName;
}
public void setPlayer(Player player) {
this.player = player;
this.playerName = player.getName();
}
public boolean loadMySQL() {
int id = 0;
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
this.userid = id;
if (id > 0) {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
if(huds.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"huds (user_id) VALUES ("+id+")");
} else {
if(huds.get(1).get(0) != null)
{
for(HUDType x : HUDType.values())
{
if(x.toString().equals(huds.get(1).get(0)))
{
hud = x;
userid = mcMMO.database.getInt("SELECT id FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
if (userid == 0) {
return false;
}
else {
HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM " + Config.getInstance().getMySQLTablePrefix() + "huds WHERE user_id = " + userid);
if (huds.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "huds (user_id) VALUES (" + userid + ")");
}
else {
if (huds.get(1).get(0) != null) {
for (HUDType x : HUDType.values()) {
if (x.toString().equals(huds.get(1).get(0))) {
hud = x;
}
}
}
} else {
hud = Config.getInstance().defaulthud;
else {
hud = SpoutConfig.getInstance().defaulthud;
}
}
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE id = " + id);
//lastlogin = Integer.parseInt(users.get(1).get(0));
party = users.get(1).get(1);
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+Config.getInstance().getMySQLTablePrefix()+"cooldowns WHERE user_id = " + id);
/*
* I'm still learning MySQL, this is a fix for adding a new table
* its not pretty but it works
*/
if(cooldowns.get(1) == null)
{
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM " + Config.getInstance().getMySQLTablePrefix() + "cooldowns WHERE user_id = " + userid);
if(cooldowns.get(1) == null) {
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
}
else
{
else {
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(cooldowns.get(1).get(0)));
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(cooldowns.get(1).get(1)));
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(cooldowns.get(1).get(2)));
@@ -143,7 +150,8 @@ public class PlayerProfile {
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
}
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + userid);
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
@@ -156,7 +164,7 @@ public class PlayerProfile {
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + id);
HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + userid);
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
@@ -172,118 +180,109 @@ public class PlayerProfile {
loaded = true;
return true;
}
else {
return false;
}
}
public void addMySQLPlayer() {
int id = 0;
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
this.userid = id;
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 + ")");
userid = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix() + "users WHERE user = '" + playerName + "'");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "skills (user_id) VALUES (" + userid + ")");
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "experience (user_id) VALUES (" + userid + ")");
}
public boolean load()
{
public boolean load() {
try {
//Open the user file
FileReader file = new FileReader(location);
BufferedReader in = new BufferedReader(file);
String line = "";
while((line = in.readLine()) != null)
{
while ((line = in.readLine()) != null) {
//Find if the line contains the player we want.
String[] character = line.split(":");
if(!character[0].equals(playerName)){continue;}
//Get Mining
if(character.length > 1 && Misc.isInt(character[1]))
if (!character[0].equals(playerName)) {
continue;
}
if (character.length > 1 && Misc.isInt(character[1]))
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
//Party
if(character.length > 3)
party = character[3];
//Mining XP
if(character.length > 4 && Misc.isInt(character[4]))
if (character.length > 4 && Misc.isInt(character[4]))
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
if(character.length > 5 && Misc.isInt(character[5]))
if (character.length > 5 && Misc.isInt(character[5]))
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
if(character.length > 6 && Misc.isInt(character[6]))
if (character.length > 6 && Misc.isInt(character[6]))
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
if(character.length > 7 && Misc.isInt(character[7]))
if (character.length > 7 && Misc.isInt(character[7]))
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
if(character.length > 8 && Misc.isInt(character[8]))
if (character.length > 8 && Misc.isInt(character[8]))
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
if(character.length > 9 && Misc.isInt(character[9]))
if (character.length > 9 && Misc.isInt(character[9]))
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
if(character.length > 10 && Misc.isInt(character[10]))
if (character.length > 10 && Misc.isInt(character[10]))
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
if(character.length > 11 && Misc.isInt(character[11]))
if (character.length > 11 && Misc.isInt(character[11]))
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
if(character.length > 12 && Misc.isInt(character[12]))
if (character.length > 12 && Misc.isInt(character[12]))
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
if(character.length > 13 && Misc.isInt(character[13]))
if (character.length > 13 && Misc.isInt(character[13]))
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
if(character.length > 14 && Misc.isInt(character[14]))
if (character.length > 14 && Misc.isInt(character[14]))
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
if(character.length > 15 && Misc.isInt(character[15]))
if (character.length > 15 && Misc.isInt(character[15]))
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
if(character.length > 16 && Misc.isInt(character[16]))
if (character.length > 16 && Misc.isInt(character[16]))
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
if(character.length > 17 && Misc.isInt(character[17]))
if (character.length > 17 && Misc.isInt(character[17]))
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
if(character.length > 18 && Misc.isInt(character[18]))
if (character.length > 18 && Misc.isInt(character[18]))
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
if(character.length > 19 && Misc.isInt(character[19]))
if (character.length > 19 && Misc.isInt(character[19]))
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
if(character.length > 20 && Misc.isInt(character[20]))
if (character.length > 20 && Misc.isInt(character[20]))
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
if(character.length > 21 && Misc.isInt(character[21]))
if (character.length > 21 && Misc.isInt(character[21]))
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
if(character.length > 22 && Misc.isInt(character[22]))
if (character.length > 22 && Misc.isInt(character[22]))
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
if(character.length > 24 && Misc.isInt(character[24]))
if (character.length > 24 && Misc.isInt(character[24]))
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
if(character.length > 25 && Misc.isInt(character[25]))
if (character.length > 25 && Misc.isInt(character[25]))
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
if(character.length > 26)
if (character.length > 26)
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
if(character.length > 27)
if (character.length > 27)
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(character[27]));
if(character.length > 28)
if (character.length > 28)
skillsDATS.put(AbilityType.TREE_FELLER, Integer.valueOf(character[28]));
if(character.length > 29)
if (character.length > 29)
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(character[29]));
if(character.length > 30)
if (character.length > 30)
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
if(character.length > 31)
if (character.length > 31)
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(character[31]));
if(character.length > 32)
if (character.length > 32)
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
if(character.length > 33)
{
for(HUDType x : HUDType.values())
{
if(x.toString().equalsIgnoreCase(character[33]))
{
if (character.length > 33) {
for (HUDType x : HUDType.values()) {
if (x.toString().equalsIgnoreCase(character[33])) {
hud = x;
}
}
}
if(character.length > 34)
if (character.length > 34)
skills.put(SkillType.FISHING, Integer.valueOf(character[34]));
if(character.length > 35)
if (character.length > 35)
skillsXp.put(SkillType.FISHING, Integer.valueOf(character[35]));
if(character.length > 36)
if (character.length > 36)
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(character[36]));
in.close();
loaded = true;
in.close();
return true;
}
in.close();
} catch (Exception e) {
mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
@@ -292,51 +291,50 @@ public class PlayerProfile {
}
public void save() {
Long timestamp = System.currentTimeMillis() / 1000; //Convert to seconds
Long timestamp = System.currentTimeMillis() / 1000;
// if we are using mysql save to database
if (Config.getInstance().getUseMySQL()) {
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"cooldowns SET "
+" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
+", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
+", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
+", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
+", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"skills SET "
+" taming = "+skills.get(SkillType.TAMING)
+", mining = "+skills.get(SkillType.MINING)
+", repair = "+skills.get(SkillType.REPAIR)
+", woodcutting = "+skills.get(SkillType.WOODCUTTING)
+", unarmed = "+skills.get(SkillType.UNARMED)
+", herbalism = "+skills.get(SkillType.HERBALISM)
+", excavation = "+skills.get(SkillType.EXCAVATION)
+", archery = " +skills.get(SkillType.ARCHERY)
+", swords = " +skills.get(SkillType.SWORDS)
+", axes = "+skills.get(SkillType.AXES)
+", acrobatics = "+skills.get(SkillType.ACROBATICS)
+", fishing = "+skills.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"experience SET "
+" taming = "+skillsXp.get(SkillType.TAMING)
+", mining = "+skillsXp.get(SkillType.MINING)
+", repair = "+skillsXp.get(SkillType.REPAIR)
+", woodcutting = "+skillsXp.get(SkillType.WOODCUTTING)
+", unarmed = "+skillsXp.get(SkillType.UNARMED)
+", herbalism = "+skillsXp.get(SkillType.HERBALISM)
+", excavation = "+skillsXp.get(SkillType.EXCAVATION)
+", archery = " +skillsXp.get(SkillType.ARCHERY)
+", swords = " +skillsXp.get(SkillType.SWORDS)
+", axes = "+skillsXp.get(SkillType.AXES)
+", acrobatics = "+skillsXp.get(SkillType.ACROBATICS)
+", fishing = "+skillsXp.get(SkillType.FISHING)
+" WHERE user_id = "+this.userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hud.toString() + "' WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
+ ", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
+ ", herbalism = " + skillsDATS.get(AbilityType.GREEN_TERRA)
+ ", excavation = " + skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)
+ ", swords = " + skillsDATS.get(AbilityType.SERRATED_STRIKES)
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+ " WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "skills SET "
+ " taming = " + skills.get(SkillType.TAMING)
+ ", mining = " + skills.get(SkillType.MINING)
+ ", repair = " + skills.get(SkillType.REPAIR)
+ ", woodcutting = " + skills.get(SkillType.WOODCUTTING)
+ ", unarmed = " + skills.get(SkillType.UNARMED)
+ ", herbalism = " + skills.get(SkillType.HERBALISM)
+ ", excavation = " + skills.get(SkillType.EXCAVATION)
+ ", archery = " + skills.get(SkillType.ARCHERY)
+ ", swords = " + skills.get(SkillType.SWORDS)
+ ", axes = " + skills.get(SkillType.AXES)
+ ", acrobatics = " + skills.get(SkillType.ACROBATICS)
+ ", fishing = " + skills.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "experience SET "
+ " taming = " + skillsXp.get(SkillType.TAMING)
+ ", mining = " + skillsXp.get(SkillType.MINING)
+ ", repair = " + skillsXp.get(SkillType.REPAIR)
+ ", woodcutting = " + skillsXp.get(SkillType.WOODCUTTING)
+ ", unarmed = " + skillsXp.get(SkillType.UNARMED)
+ ", herbalism = " + skillsXp.get(SkillType.HERBALISM)
+ ", excavation = " + skillsXp.get(SkillType.EXCAVATION)
+ ", archery = " + skillsXp.get(SkillType.ARCHERY)
+ ", swords = " + skillsXp.get(SkillType.SWORDS)
+ ", axes = " + skillsXp.get(SkillType.AXES)
+ ", acrobatics = " + skillsXp.get(SkillType.ACROBATICS)
+ ", fishing = " + skillsXp.get(SkillType.FISHING)
+ " WHERE user_id = " + userid);
}
else {
// otherwise save to flatfile
@@ -359,7 +357,7 @@ public class PlayerProfile {
writer.append(playerName + ":");
writer.append(skills.get(SkillType.MINING) + ":");
writer.append("" + ":");
writer.append(party+":");
writer.append("" + ":");
writer.append(skillsXp.get(SkillType.MINING) + ":");
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
@@ -379,19 +377,19 @@ public class PlayerProfile {
writer.append(skillsXp.get(SkillType.SWORDS) + ":");
writer.append(skillsXp.get(SkillType.AXES) + ":");
writer.append(skillsXp.get(SkillType.ACROBATICS) + ":");
writer.append(""+":");
writer.append("" + ":");
writer.append(skills.get(SkillType.TAMING) + ":");
writer.append(skillsXp.get(SkillType.TAMING) + ":");
//Need to store the DATS of abilities nao
//Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))+":");
writer.append(hud.toString()+":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BERSERK)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER)) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER)) + ":");
writer.append(hud.toString() + ":");
writer.append(skills.get(SkillType.FISHING) + ":");
writer.append(skillsXp.get(SkillType.FISHING) + ":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING)) + ":");
@@ -411,73 +409,53 @@ public class PlayerProfile {
}
}
public void resetAllData() {
//This will reset everything to default values and then save the information to FlatFile/MySQL
for (SkillType skillType : SkillType.values()) {
if (skillType != SkillType.ALL) {
skills.put(skillType, 0);
skillsXp.put(skillType, 0);
}
}
for (AbilityType abilityType : AbilityType.values()) {
skillsDATS.put(abilityType, 0);
}
//Misc stuff
party = "";
save();
}
public void addPlayer()
{
public void addPlayer() {
try {
//Open the file to write the player
FileWriter file = new FileWriter(location, true);
BufferedWriter out = new BufferedWriter(file);
//Add the player to the end
out.append(playerName + ":");
out.append(0 + ":"); //mining
out.append(""+":");
out.append(party+":");
out.append(0+":"); //XP
out.append(0+":"); //woodcutting
out.append(0+":"); //woodCuttingXP
out.append(0+":"); //repair
out.append(0+":"); //unarmed
out.append(0+":"); //herbalism
out.append(0+":"); //excavation
out.append(0+":"); //archery
out.append(0+":"); //swords
out.append(0+":"); //axes
out.append(0+":"); //acrobatics
out.append(0+":"); //repairXP
out.append(0+":"); //unarmedXP
out.append(0+":"); //herbalismXP
out.append(0+":"); //excavationXP
out.append(0+":"); //archeryXP
out.append(0+":"); //swordsXP
out.append(0+":"); //axesXP
out.append(0+":"); //acrobaticsXP
out.append(""+":");
out.append(0+":"); //taming
out.append(0+":"); //tamingXP
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(0+":"); //DATS
out.append(Config.getInstance().defaulthud.toString()+":");//HUD
out.append(0+":"); //Fishing
out.append(0+":"); //FishingXP
out.append(0+":"); //Blast Mining
out.append("" + ":");
out.append("" + ":");
out.append(0 + ":"); //XP
out.append(0 + ":"); //woodcutting
out.append(0 + ":"); //woodCuttingXP
out.append(0 + ":"); //repair
out.append(0 + ":"); //unarmed
out.append(0 + ":"); //herbalism
out.append(0 + ":"); //excavation
out.append(0 + ":"); //archery
out.append(0 + ":"); //swords
out.append(0 + ":"); //axes
out.append(0 + ":"); //acrobatics
out.append(0 + ":"); //repairXP
out.append(0 + ":"); //unarmedXP
out.append(0 + ":"); //herbalismXP
out.append(0 + ":"); //excavationXP
out.append(0 + ":"); //archeryXP
out.append(0 + ":"); //swordsXP
out.append(0 + ":"); //axesXP
out.append(0 + ":"); //acrobaticsXP
out.append("" + ":");
out.append(0 + ":"); //taming
out.append(0 + ":"); //tamingXP
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(0 + ":"); //DATS
out.append(SpoutConfig.getInstance().defaulthud.toString() + ":");//HUD
out.append(0 + ":"); //Fishing
out.append(0 +":"); //FishingXP
out.append(0 + ":"); //Blast Mining
//Add more in the same format as the line above
out.newLine();
out.close();
} catch (Exception e) {
@@ -489,10 +467,6 @@ public class PlayerProfile {
* mySQL Stuff
*/
public int getLastLogin() {
return lastlogin;
}
public int getMySQLuserId() {
return userid;
}
@@ -606,18 +580,6 @@ public class PlayerProfile {
partyChatMode = !partyChatMode;
}
/*
* Exploit Prevention
*/
public long getRespawnATS() {
return respawnATS;
}
public void setRespawnATS(long newvalue) {
respawnATS = (int) (newvalue / 1000);
}
/*
* Tools
*/
@@ -902,12 +864,16 @@ public class PlayerProfile {
* Recently Hurt
*/
public long getRecentlyHurt() {
public int getRecentlyHurt() {
return recentlyHurt;
}
public void setRecentlyHurt(long newvalue) {
recentlyHurt = (int) (newvalue / 1000);
public void setRecentlyHurt(int value) {
recentlyHurt = value;
}
public void actualizeRecentlyHurt() {
respawnATS = (int) (System.currentTimeMillis() / 1000);
}
/*
@@ -944,6 +910,18 @@ public class PlayerProfile {
}
}
/*
* Exploit Prevention
*/
public int getRespawnATS() {
return respawnATS;
}
public void actualizeRespawnATS() {
respawnATS = (int) (System.currentTimeMillis() / 1000);
}
/*
* XP Functions
*/
@@ -967,8 +945,6 @@ public class PlayerProfile {
* @param newValue The amount of XP to add
*/
public void addXPOverride(SkillType skillType, int newValue) {
Player player = mcMMO.p.getServer().getPlayer(playerName);
if (skillType.equals(SkillType.ALL)) {
for (SkillType x : SkillType.values()) {
if (x.equals(SkillType.ALL)) {
@@ -998,20 +974,16 @@ public class PlayerProfile {
}
/**
* Adds XP to the player, this is affected by skill modifiers and XP Rate
* Adds XP to the player, this is affected by skill modifiers and XP Rate and Permissions
*
* @param skillType The skill to add XP to
* @param newvalue The amount of XP to add
* @param player The player to add XP to
*/
public void addXP(SkillType skillType, int newValue) {
Player player = mcMMO.p.getServer().getPlayer(playerName);
if (System.currentTimeMillis() < ((xpGainATS * 1000) + 250) || player.getGameMode().equals(GameMode.CREATIVE)) {
if (player.getGameMode().equals(GameMode.CREATIVE)) {
return;
}
xpGainATS = (int) (System.currentTimeMillis() / 1000); //Setup a timestamp of when xp was given
double bonusModifier = 0;
if (inParty()) {
@@ -1029,6 +1001,25 @@ public class PlayerProfile {
xp += trueBonus;
}
if (Config.getInstance().getToolModsEnabled()) {
ItemStack item = player.getItemInHand();
CustomTool tool = ModChecks.getToolFromItemStack(item);
if (tool != null) {
xp = (int) (xp * tool.getXpMultiplier());
}
}
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
xp = xp * 4;
}
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
xp = xp * 3;
}
else if (player.hasPermission("mcmmo.perks.xp.double")) {
xp = xp * 2;
}
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
lastgained = skillType;
@@ -1076,8 +1067,6 @@ public class PlayerProfile {
skills.put(skillType, newValue);
skillsXp.put(skillType, 0);
}
save();
}
/**
@@ -1112,7 +1101,7 @@ public class PlayerProfile {
* @return the XP remaining until next level
*/
public int getXpToLevel(SkillType skillType) {
return (int) (1020 + (skills.get(skillType) * 20)); //Do we REALLY need to cast to int here?
return 1020 + (skills.get(skillType) * Config.getInstance().getFormulaMultiplierCurve()); //Do we REALLY need to cast to int here?
}
/**
@@ -1121,7 +1110,6 @@ public class PlayerProfile {
* @return the power level of the player
*/
public int getPowerLevel() {
Player player = mcMMO.p.getServer().getPlayer(playerName);
int powerLevel = 0;
for (SkillType type : SkillType.values()) {
@@ -1140,15 +1128,12 @@ public class PlayerProfile {
* @return the party bonus multiplier
*/
private double partyModifier(SkillType skillType) {
Player player = getPlayer();
double bonusModifier = 0.0;
for (Player x : Party.getInstance().getOnlineMembers(player)) {
String memberName = x.getName();
if (!memberName.equals(playerName) && Party.getInstance().isPartyLeader(memberName, getParty())) {
if (Misc.isNear(player.getLocation(), x.getLocation(), 25.0)) {
PlayerProfile PartyLeader = Users.getProfile(x);
for (Player member : party.getOnlineMembers()) {
if (party.getLeader().equals(member.getName())) {
if (Misc.isNear(player.getLocation(), member.getLocation(), 25.0)) {
PlayerProfile PartyLeader = Users.getProfile(member);
int leaderSkill = PartyLeader.getSkillLevel(skillType);
int playerSkill = getSkillLevel(skillType);
@@ -1167,21 +1152,16 @@ public class PlayerProfile {
* Party Stuff
*/
public void acceptInvite() {
party = invite;
invite = "";
public void setInvite(Party invite) {
this.invite = invite;
}
public void modifyInvite(String invitename) {
invite = invitename;
}
public String getInvite() {
public Party getInvite() {
return invite;
}
public boolean hasPartyInvite() {
if (invite != null && !invite.equals("") && !invite.equals("null")) {
if (invite != null) {
return true;
}
else {
@@ -1189,24 +1169,28 @@ public class PlayerProfile {
}
}
public void setParty(String newParty) {
party = newParty;
public void setParty(Party party) {
this.party = party;
}
public String getParty() {
public Party getParty() {
return party;
}
public boolean inParty() {
if (party != null) {
return true;
}
else {
return false;
}
}
public void removeParty() {
party = null;
}
public boolean inParty() {
if (party != null && !party.equals("") && !party.equals("null")) {
return true;
}
else {
return false;
}
public void removeInvite() {
invite = null;
}
}

View File

@@ -48,7 +48,7 @@ public enum ToolType {
return ItemChecks.isHoe(is);
case PICKAXE:
return ItemChecks.isMiningPick(is);
return ItemChecks.isPickaxe(is);
case SHOVEL:
return ItemChecks.isShovel(is);

View File

@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class Tree {
private TreeNode root = null;

View File

@@ -2,8 +2,6 @@ package com.gmail.nossr50.datatypes;
import java.util.ArrayList;
import com.gmail.nossr50.datatypes.PlayerStat;
public class TreeNode {
TreeNode left = null;
TreeNode right = null;

View File

@@ -0,0 +1,59 @@
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;
public CustomBlock(ItemStack itemDrop, int tier, int xpGain, byte dataValue, int itemID) {
this.itemID = itemID;
this.dataValue = dataValue;
this.xpGain = xpGain;
this.tier = tier;
this.itemDrop = itemDrop;
}
public int getItemID() {
return itemID;
}
public void setItemID(int itemID) {
this.itemID = itemID;
}
public byte getDataValue() {
return dataValue;
}
public void setDataValue(byte dataValue) {
this.dataValue = dataValue;
}
public int getXpGain() {
return xpGain;
}
public void setXpGain(int xpGain) {
this.xpGain = xpGain;
}
public int getTier() {
return tier;
}
public void setTier(int tier) {
this.tier = tier;
}
public ItemStack getItemDrop() {
return itemDrop;
}
public void setItemDrop(ItemStack itemDrop) {
this.itemDrop = itemDrop;
}
}

View File

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

View File

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

View File

@@ -4,16 +4,15 @@ import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.getspout.spoutapi.gui.GenericLabel;
import org.getspout.spoutapi.gui.GenericPopup;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
public class PopupMMO extends GenericPopup {
private ButtonHUDStyle HUDButton = null;
private ButtonPartyToggle PartyButton = null;
private ButtonEscape EscapeButton = null;
private GenericLabel mcMMO_label = new GenericLabel();
private GenericLabel tip_escape = new GenericLabel();
@@ -53,7 +52,7 @@ public class PopupMMO extends GenericPopup {
public void updateButtons(PlayerProfile PP) {
HUDButton.updateText(PP);
PartyButton.updateText(PP);
//PartyButton.updateText(PP);
this.setDirty(true);
}
}

View File

@@ -4,7 +4,7 @@ import org.bukkit.inventory.ItemStack;
public abstract class Treasure {
private int xp;
private Double dropChance;
private double dropChance;
private int dropLevel;
private ItemStack drop;
@@ -31,7 +31,7 @@ public abstract class Treasure {
this.xp = xp;
}
public Double getDropChance() {
public double getDropChance() {
return dropChance;
}

View File

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

View File

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

View File

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

View File

@@ -2,27 +2,6 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.skills.Excavation;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Mining;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.WoodCutting;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -32,14 +11,36 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.getspout.spoutapi.sound.SoundEffect;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.datatypes.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.skills.gathering.Excavation;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.gathering.Mining;
import com.gmail.nossr50.skills.gathering.WoodCutting;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.ModChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class BlockListener implements Listener {
private final mcMMO plugin;
@@ -58,16 +59,35 @@ public class BlockListener implements Listener {
BlockFace direction = event.getDirection();
for (Block b : blocks) {
if (b.hasMetadata("mcmmoPlacedBlock")) {
b.getRelative(direction).setMetadata("mcmmoNeedsTracking", new FixedMetadataValue(plugin, true));
b.removeMetadata("mcmmoPlacedBlock", plugin);
}
if (mcMMO.placeStore.isTrue(b)) {
b.getRelative(direction).setMetadata("pistonTrack", new FixedMetadataValue(plugin, true));
mcMMO.placeStore.setFalse(b);
}
}
for (Block b : blocks) {
if (b.getRelative(direction).hasMetadata("mcmmoNeedsTracking")) {
b.getRelative(direction).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
b.getRelative(direction).removeMetadata("mcmmoNeedsTracking", plugin);
if (b.getRelative(direction).hasMetadata("pistonTrack")) {
mcMMO.placeStore.setTrue(b.getRelative(direction));
b.getRelative(direction).removeMetadata("pistonTrack", plugin);
}
}
}
/**
* Monitor BlockPhysics events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPhysics(BlockPhysicsEvent event) {
//TODO: Figure out how to REMOVE metadata from the location the sand/gravel fell from.
Material type = event.getChangedType();
if (type == Material.GRAVEL || type == Material.SAND) {
Block fallenBlock = event.getBlock().getRelative(BlockFace.UP);
if (fallenBlock.getType() == type) {
mcMMO.placeStore.setTrue(fallenBlock);
}
}
}
@@ -81,9 +101,9 @@ public class BlockListener implements Listener {
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
Block block = event.getRetractLocation().getBlock();
if (block.hasMetadata("mcmmoPlacedBlock")) {
block.removeMetadata("mcmmoPlacedBlock", plugin);
event.getBlock().getRelative(event.getDirection()).setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
if (event.isSticky() && mcMMO.placeStore.isTrue(block)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.setTrue(event.getBlock().getRelative(event.getDirection()));
}
}
@@ -94,31 +114,35 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Config configInstance = Config.getInstance();
Block block = event.getBlock();
Player player = event.getPlayer();
int id = block.getTypeId();
Material mat = block.getType();
Material type = block.getType();
/* Code to prevent issues with placed falling Sand/Gravel not being tracked */
if (mat.equals(Material.SAND) || mat.equals(Material.GRAVEL)) {
if (type.equals(Material.SAND) || type.equals(Material.GRAVEL)) {
for (int y = -1; y + block.getY() >= 0; y--) {
if (block.getRelative(0, y, 0).getType().equals(Material.AIR)) {
continue;
}
else {
Block newLocation = block.getRelative(0, y + 1, 0);
newLocation.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
mcMMO.placeStore.setTrue(newLocation);
break;
}
}
}
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockChecks.shouldBeWatched(mat)) {
block.setMetadata("mcmmoPlacedBlock", new FixedMetadataValue(plugin, true));
if (BlockChecks.shouldBeWatched(block)) {
if (!((type == Material.SAND || type == Material.GRAVEL) && block.getRelative(BlockFace.DOWN).getType() == Material.AIR)) { //Don't wanna track sand that's gonna fall.
mcMMO.placeStore.setTrue(block);
}
}
if (id == Config.getInstance().getRepairAnvilId() && Config.getInstance().getRepairAnvilMessagesEnabled()) {
if (id == configInstance.getRepairAnvilId() && configInstance.getRepairAnvilMessagesEnabled()) {
Repair.placedAnvilCheck(player, id);
}
}
@@ -133,77 +157,102 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
Block block = event.getBlock();
Material mat = block.getType();
ItemStack inhand = player.getItemInHand();
ItemStack inHand = player.getItemInHand();
Config configInstance = Config.getInstance();
Permissions permInstance = Permissions.getInstance();
if (event instanceof FakeBlockBreakEvent) {
return;
}
/*
* HERBALISM
*/
/* Green Terra */
if (PP.getToolPreparationMode(ToolType.HOE) && Permissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
/* Triple drops */
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
if (Permissions.getInstance().herbalism(player) && Herbalism.canBeGreenTerra(mat)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
/*
* MINING
*/
if (Permissions.getInstance().mining(player) && Mining.canBeSuperBroken(mat)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
Mining.miningBlockCheck(player, block);
/* HERBALISM */
if (BlockChecks.canBeGreenTerra(block)) {
/* Green Terra */
if (PP.getToolPreparationMode(ToolType.HOE) && permInstance.greenTerra(player)) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (!Config.getInstance().getMiningRequiresTool()) {
/* Triple drops */
if (PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
if (permInstance.herbalism(player)) {
Herbalism.herbalismProcCheck(block, player, event, plugin);
}
}
/* MINING */
else if (BlockChecks.canBeSuperBroken(block) && permInstance.mining(player)) {
if (configInstance.getMiningRequiresTool()) {
if (ItemChecks.isPickaxe(inHand)) {
Mining.miningBlockCheck(player, block);
}
}
else {
Mining.miningBlockCheck(player, block);
}
}
/*
* WOOD CUTTING
*/
if (Permissions.getInstance().woodcutting(player) && mat.equals(Material.LOG)) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
/* WOOD CUTTING */
else if (BlockChecks.isLog(block) && permInstance.woodcutting(player)) {
if (configInstance.getWoodcuttingRequiresTool()) {
if (ItemChecks.isAxe(inHand)) {
WoodCutting.woodcuttingBlockCheck(player, block);
}
}
else {
WoodCutting.woodcuttingBlockCheck(player, block);
}
else if (!Config.getInstance().getWoodcuttingRequiresTool()) {
WoodCutting.woodcuttingBlockCheck(player, block);
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && permInstance.treeFeller(player) && ItemChecks.isAxe(inHand)) {
if (ModChecks.isCustomTool(inHand)) {
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
WoodCutting.treeFeller(event);
}
}
else {
WoodCutting.treeFeller(event);
}
}
}
if (PP.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.getInstance().treeFeller(player) && ItemChecks.isAxe(inhand)) {
WoodCutting.treeFeller(event);
}
/*
* EXCAVATION
*/
if (Excavation.canBeGigaDrillBroken(mat) && Permissions.getInstance().excavation(player) && !block.hasMetadata("mcmmoPlacedBlock")) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
Excavation.excavationProcCheck(block, player);
/* EXCAVATION */
else if (BlockChecks.canBeGigaDrillBroken(block) && permInstance.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
if (configInstance.getExcavationRequiresTool()) {
if (ItemChecks.isShovel(inHand)) {
Excavation.excavationProcCheck(block, player);
}
}
else if (!Config.getInstance().getExcavationRequiresTool()) {
else {
Excavation.excavationProcCheck(block, player);
}
}
//Remove metadata when broken
if (block.hasMetadata("mcmmoPlacedBlock") && BlockChecks.shouldBeWatched(mat)) {
block.removeMetadata("mcmmoPlacedBlock", plugin);
if (mcMMO.placeStore.isTrue(block) && BlockChecks.shouldBeWatched(block)) {
mcMMO.placeStore.setFalse(block);
}
//Remove metadata from fallen sand/gravel
Material aboveType = block.getRelative(BlockFace.UP).getType();
if (aboveType == Material.SAND || aboveType == Material.GRAVEL) {
for (int y = 1; block.getY() + y <= block.getWorld().getMaxHeight(); y++) {
Block relative = block.getRelative(0, y, 0);
Material relativeType = relative.getType();
if ((relativeType == Material.SAND || relativeType == Material.GRAVEL) && mcMMO.placeStore.isTrue(relative)) {
mcMMO.placeStore.setFalse(relative);
}
else if (!BlockChecks.shouldBeWatched(relative) && mcMMO.placeStore.isTrue(relative)){
mcMMO.placeStore.setFalse(relative);
}
else {
break;
}
}
}
}
@@ -214,87 +263,122 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) {
return;
}
final int LEAF_BLOWER_LEVEL = 100;
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
ItemStack inhand = player.getItemInHand();
ItemStack inHand = player.getItemInHand();
Block block = event.getBlock();
Material mat = block.getType();
Material material = block.getType();
Config configInstance = Config.getInstance();
Permissions permInstance = Permissions.getInstance();
/*
* ABILITY PREPARATION CHECKS
*/
if (BlockChecks.abilityBlockCheck(mat)) {
if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
if (BlockChecks.abilityBlockCheck(block)) {
if (PP.getToolPreparationMode(ToolType.HOE) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.makeMossy(block))) {
Skills.abilityCheck(player, SkillType.HERBALISM);
}
else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && Permissions.getInstance().treeFeller(player)) { //Why are we checking the permissions here?
else if (PP.getToolPreparationMode(ToolType.AXE) && BlockChecks.isLog(block) && permInstance.treeFeller(player)) { //TODO: Why are we checking the permissions here?
Skills.abilityCheck(player, SkillType.WOODCUTTING);
}
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
else if (PP.getToolPreparationMode(ToolType.PICKAXE) && BlockChecks.canBeSuperBroken(block)) {
Skills.abilityCheck(player, SkillType.MINING);
}
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && Excavation.canBeGigaDrillBroken(mat)) {
else if (PP.getToolPreparationMode(ToolType.SHOVEL) && BlockChecks.canBeGigaDrillBroken(block)) {
Skills.abilityCheck(player, SkillType.EXCAVATION);
}
else if (PP.getToolPreparationMode(ToolType.FISTS) && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
else if (PP.getToolPreparationMode(ToolType.FISTS) && (BlockChecks.canBeGigaDrillBroken(block) || material.equals(Material.SNOW))) {
Skills.abilityCheck(player, SkillType.UNARMED);
}
}
/* TREE FELLER SOUNDS */
if (Config.getInstance().spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
if (mcMMO.spoutEnabled && BlockChecks.isLog(block) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
}
/*
* ABILITY TRIGGER CHECKS
*/
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Permissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
Herbalism.greenTerra(player, block);
if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && permInstance.greenTerra(player) && BlockChecks.makeMossy(block)) {
if (ModChecks.isCustomTool(inHand)) {
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
Herbalism.greenTerra(player, block);
}
}
else {
Herbalism.greenTerra(player, block);
}
}
else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (Config.getInstance().getExcavationRequiresTool() && ItemChecks.isShovel(inhand)) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
if (configInstance.getExcavationRequiresTool()) {
if (ItemChecks.isShovel(inHand)) {
if (ModChecks.isCustomTool(inHand)) {
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
}
else if (!Config.getInstance().getExcavationRequiresTool()) {
else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(player, block);
}
}
else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
if (inhand.getType().equals(Material.AIR)) {
if (inHand.getType().equals(Material.AIR)) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
plugin.getServer().getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
}
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
if (Config.getInstance().getMiningRequiresTool() && ItemChecks.isMiningPick(inhand)) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
}
else if (!Config.getInstance().getMiningRequiresTool()) {
event.setInstaBreak(true);
Mining.SuperBreakerBlockCheck(player, block);
}
}
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && mat.equals(Material.LEAVES)) {
if (Config.getInstance().getWoodcuttingRequiresTool() && ItemChecks.isAxe(inhand)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
if (configInstance.getMiningRequiresTool()) {
if (ItemChecks.isPickaxe(inHand)) {
if (ModChecks.isCustomTool(inHand)) {
if (ModChecks.getToolFromItemStack(inHand).isAbilityEnabled()) {
event.setInstaBreak(true);
Mining.superBreakerBlockCheck(player, block);
}
}
else {
event.setInstaBreak(true);
Mining.superBreakerBlockCheck(player, block);
}
}
}
else if (!Config.getInstance().getWoodcuttingRequiresTool() && !inhand.getType().equals(Material.SHEARS)) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
else {
event.setInstaBreak(true);
Mining.superBreakerBlockCheck(player, block);
}
}
else if (PP.getSkillLevel(SkillType.WOODCUTTING) >= LEAF_BLOWER_LEVEL && (material.equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block)))) {
if (Skills.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) {
if (configInstance.getWoodcuttingRequiresTool()) {
if (ItemChecks.isAxe(inHand)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}
}
else if (!inHand.getType().equals(Material.SHEARS)) {
event.setInstaBreak(true);
WoodCutting.leafBlower(player, block);
}

View File

@@ -1,11 +1,14 @@
package com.gmail.nossr50.listeners;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -28,16 +31,16 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.Acrobatics;
import com.gmail.nossr50.skills.Archery;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
import com.gmail.nossr50.skills.archery.Archery;
import com.gmail.nossr50.skills.gathering.BlastMining;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class EntityListener implements Listener {
@@ -58,15 +61,22 @@ public class EntityListener implements Listener {
return;
}
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
Entity defender = event.getEntity();
if (attacker instanceof Projectile) {
attacker = ((Projectile) attacker).getShooter();
}
else if (attacker instanceof Tameable) {
AnimalTamer animalTamer = ((Tameable) attacker).getOwner();
if (animalTamer instanceof Entity) {
attacker = (Entity) animalTamer;
}
}
if (attacker instanceof Player && defender instanceof Player) {
if (!defender.getWorld().getPVP()) {
return;
}
if (Party.getInstance().inSameParty((Player)defender, (Player)attacker)) {
if (PartyManager.getInstance().inSameParty((Player) defender, (Player) attacker)) {
event.setCancelled(true);
return;
}
@@ -74,10 +84,10 @@ public class EntityListener implements Listener {
/* Check for invincibility */
if (defender instanceof LivingEntity) {
LivingEntity livingDefender = (LivingEntity)defender;
LivingEntity livingDefender = (LivingEntity) defender;
if (!Misc.isInvincible(livingDefender, event)) {
Combat.combatChecks(event, plugin);
Combat.combatChecks(event);
}
}
}
@@ -94,12 +104,15 @@ public class EntityListener implements Listener {
}
Entity entity = event.getEntity();
EntityType type = entity.getType();
DamageCause cause = event.getCause();
switch(type) {
case PLAYER:
if (!(entity instanceof LivingEntity)) {
return;
}
LivingEntity lEntity = (LivingEntity) entity;
if (lEntity instanceof Player) {
/* Check for invincibility */
Player player = (Player) entity;
PlayerProfile PP = Users.getProfile(player);
@@ -110,29 +123,26 @@ public class EntityListener implements Listener {
}
if (!Misc.isInvincible(player, event)) {
if (cause == DamageCause.FALL && Permissions.getInstance().acrobatics(player)) {
Acrobatics.acrobaticsCheck(player, event);
if (cause == DamageCause.FALL && !player.isInsideVehicle() && !(player.getItemInHand().getType() == Material.ENDER_PEARL)) {
AcrobaticsManager acroManager = new AcrobaticsManager(player);
acroManager.rollCheck(event);
}
else if (cause == DamageCause.BLOCK_EXPLOSION && Permissions.getInstance().demolitionsExpertise(player)) {
BlastMining.demolitionsExpertise(player, event);
}
if (event.getDamage() >= 1) {
PP.setRecentlyHurt(System.currentTimeMillis());
PP.actualizeRecentlyHurt();
}
}
break;
} else if (lEntity instanceof Tameable) {
Tameable pet = (Tameable) lEntity;
AnimalTamer owner = pet.getOwner();
case WOLF:
Wolf wolf = (Wolf) entity;
if ((!Misc.isInvincible(wolf, event)) && wolf.isTamed() && (wolf.getOwner() instanceof Player)) {
Taming.preventDamage(event);
if ((!Misc.isInvincible(lEntity, event)) && pet.isTamed() && (owner instanceof Player) && pet instanceof Wolf) {
TamingManager tamingManager = new TamingManager((Player) owner);
tamingManager.preventDamage(event);
}
break;
default:
break;
}
}
@@ -144,12 +154,10 @@ public class EntityListener implements Listener {
@EventHandler (priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
LivingEntity entity = event.getEntity();
entity.setFireTicks(0);
/* Remove bleed track */
BleedTimer.remove(entity);
Archery.arrowRetrievalCheck(entity, plugin);
Archery.arrowRetrievalCheck(entity);
}
/**
@@ -178,8 +186,8 @@ public class EntityListener implements Listener {
if (entity instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
if (Permissions.getInstance().biggerBombs(player)) {
BlastMining.biggerBombs(player, event);
@@ -200,10 +208,10 @@ public class EntityListener implements Listener {
if (event.getEntity() instanceof TNTPrimed) {
int id = entity.getEntityId();
if (plugin.tntTracker.containsKey(id)) {
Player player = plugin.tntTracker.get(id);
if (plugin.tntIsTracked(id)) {
Player player = plugin.getTNTPlayer(id);
BlastMining.dropProcessing(player, event);
plugin.tntTracker.remove(id);
plugin.removeFromTNTTracker(id);
}
}
}
@@ -215,65 +223,67 @@ public class EntityListener implements Listener {
*/
@EventHandler (priority = EventPriority.LOW)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
if (Config.getInstance().getHerbalismHungerBonusEnabled()) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PlayerProfile PP = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
PlayerProfile PP = Users.getProfile(player);
int currentFoodLevel = player.getFoodLevel();
int newFoodLevel = event.getFoodLevel();
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
* The number of ranks is based on how 'common' the item is
* We can adjust this quite easily if we find something is giving too much of a bonus
*/
if (!Permissions.getInstance().farmersDiet(player)) {
return;
}
if (newFoodLevel > currentFoodLevel) {
Material food = player.getItemInHand().getType();
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
int foodChange = newFoodLevel - currentFoodLevel;
int rankChange = 0;
/*
* Some foods have 3 ranks
* Some foods have 5 ranks
* The number of ranks is based on how 'common' the item is
* We can adjust this quite easily if we find something is giving too much of a bonus
*/
switch (food) {
case BREAD:
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = 200;
break;
if (newFoodLevel > currentFoodLevel) {
Material food = player.getItemInHand().getType();
int herbLevel = PP.getSkillLevel(SkillType.HERBALISM);
int foodChange = newFoodLevel - currentFoodLevel;
int rankChange = 0;
case COOKIE:
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
rankChange = 400;
break;
switch (food) {
case BREAD:
/* BREAD RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
rankChange = 200;
break;
case MELON:
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = 400;
break;
case COOKIE:
/* COOKIE RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
rankChange = 400;
break;
case MUSHROOM_SOUP:
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
rankChange = 200;
break;
case MELON:
/* MELON RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
rankChange = 400;
break;
default:
return;
case MUSHROOM_SOUP:
/* MUSHROOM SOUP RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @ 1000 */
rankChange = 200;
break;
default:
return;
}
for (int i = 200; i <= 1000; i += rankChange) {
if (herbLevel >= i) {
foodChange++;
}
}
for (int i = 200; i <= 1000; i += rankChange) {
if (herbLevel >= i) {
foodChange++;
}
}
/* Make sure we don't go over the max value */
newFoodLevel = currentFoodLevel + foodChange;
if (newFoodLevel > 20) {
event.setFoodLevel(20);
}
else {
event.setFoodLevel(newFoodLevel);
}
/* Make sure we don't go over the max value */
newFoodLevel = currentFoodLevel + foodChange;
if (newFoodLevel > 20) {
event.setFoodLevel(20);
}
else {
event.setFoodLevel(newFoodLevel);
}
}
}
@@ -306,8 +316,7 @@ public class EntityListener implements Listener {
break;
}
PP.addXP(SkillType.TAMING, xp);
Skills.XpCheckSkill(SkillType.TAMING, player);
Skills.xpProcessing(player, PP, SkillType.TAMING, xp);
}
}
}

View File

@@ -0,0 +1,34 @@
package com.gmail.nossr50.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Hardcore;
import com.gmail.nossr50.util.Permissions;
public class HardcoreListener implements Listener {
/**
* Monitor PlayerDeath events.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity(); //Note this returns a Player object for this subevent
if (!Permissions.getInstance().hardcoremodeBypass(player)) {
if (player.getKiller() instanceof Player) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(player.getKiller(), player);
}
}
Hardcore.invokeStatPenalty(player);
}
}
}

View File

@@ -1,12 +1,8 @@
package com.gmail.nossr50.listeners;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -22,14 +18,12 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
@@ -37,16 +31,16 @@ import com.gmail.nossr50.events.chat.McMMOAdminChatEvent;
import com.gmail.nossr50.events.chat.McMMOPartyChatEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.skills.BlastMining;
import com.gmail.nossr50.skills.Fishing;
import com.gmail.nossr50.skills.Herbalism;
import com.gmail.nossr50.skills.Repair;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.skills.Taming;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.skills.gathering.BlastMining;
import com.gmail.nossr50.skills.gathering.Fishing;
import com.gmail.nossr50.skills.gathering.Herbalism;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Item;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class PlayerListener implements Listener {
@@ -129,7 +123,7 @@ public class PlayerListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLogin(PlayerLoginEvent event) {
Users.addUser(event.getPlayer());
Users.addUser(event.getPlayer()).actualizeRespawnATS();
}
/**
@@ -144,15 +138,12 @@ public class PlayerListener implements Listener {
/* GARBAGE COLLECTION */
//Remove Spout Stuff
if (Config.getInstance().spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
if (mcMMO.spoutEnabled && SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.remove(player);
}
//Bleed it out
BleedTimer.bleedOut(player);
//Schedule PlayerProfile removal 2 minutes after quitting
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new RemoveProfileFromMemoryTask(player.getName()), 2400);
}
/**
@@ -164,9 +155,37 @@ public class PlayerListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Permissions.getInstance().motd(player) && Config.getInstance().getMOTDEnabled()) {
player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
player.sendMessage(LocaleLoader.getString("mcMMO.Wiki"));
//TODO: Locale ALL the things.
if (Config.getInstance().getMOTDEnabled() && Permissions.getInstance().motd(player)) {
String prefix = ChatColor.GOLD + "[mcMMO] ";
String perkPrefix = ChatColor.RED + "[mcMMO Perks] ";
player.sendMessage(prefix + ChatColor.YELLOW + "Running version " + ChatColor.DARK_AQUA + plugin.getDescription().getVersion()); //TODO: Locale
if (Config.getInstance().getHardcoreEnabled()) {
if (Config.getInstance().getHardcoreVampirismEnabled()) {
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore & Vampirism enabled.");
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "% " + ChatColor.DARK_AQUA + "Vampirism Stat Leech: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreVampirismStatLeechPercentage() + "%");
}
else {
player.sendMessage(prefix + ChatColor.DARK_RED + "Hardcore enabled.");
player.sendMessage(prefix + ChatColor.DARK_AQUA + "Skill Death Penalty: " + ChatColor.DARK_RED + Config.getInstance().getHardcoreDeathStatPenaltyPercentage() + "%");
}
}
if (player.hasPermission("mcmmo.perks.xp.quadruple")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Quadruple XP - Receive 4x XP.");
}
else if (player.hasPermission("mcmmo.perks.xp.triple")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Triple XP - Receive 3x XP.");
}
else if (player.hasPermission("mcmmo.perks.xp.double")) {
player.sendMessage(perkPrefix + ChatColor.DARK_AQUA + "Double XP - Receive 2x XP.");
}
player.sendMessage(ChatColor.GOLD+"[mcMMO] " + ChatColor.GREEN + "http://www.mcmmo.info" + ChatColor.YELLOW + " - mcMMO Website & Forums"); //TODO: Locale
//player.sendMessage(LocaleLoader.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()}));
//player.sendMessage(LocaleLoader.getString("mcMMO.Website"));
}
//THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY
@@ -175,6 +194,11 @@ public class PlayerListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Users.getProfile(event.getPlayer()).actualizeRespawnATS();
}
/**
* Monitor PlayerInteract events.
*
@@ -183,33 +207,34 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
Block block = event.getClickedBlock();
ItemStack is = player.getItemInHand();
Material mat;
ItemStack inHand = player.getItemInHand();
Material material;
/* Fix for NPE on interacting with air */
if (block == null) {
mat = Material.AIR;
material = Material.AIR;
}
else {
mat = block.getType();
material = block.getType();
}
switch (action) {
case RIGHT_CLICK_BLOCK:
/* REPAIR CHECKS */
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId() && (ItemChecks.isTool(is) || ItemChecks.isArmor(is))) {
Repair.repairCheck(player, is);
event.setCancelled(true);
player.updateInventory();
if (Permissions.getInstance().repair(player) && block.getTypeId() == Config.getInstance().getRepairAnvilId()) {
if (mcMMO.repairManager.isRepairable(inHand)) {
mcMMO.repairManager.handleRepair(player, inHand);
event.setCancelled(true);
player.updateInventory();
}
}
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(mat)) {
if (!mat.equals(Material.DIRT) && !mat.equals(Material.GRASS) && !mat.equals(Material.SOIL)) {
if (Config.getInstance().getAbilitiesEnabled() && BlockChecks.abilityBlockCheck(block)) {
if (!material.equals(Material.DIRT) && !material.equals(Material.GRASS) && !material.equals(Material.SOIL)) {
Skills.activationCheck(player, SkillType.HERBALISM);
}
@@ -222,17 +247,17 @@ public class PlayerListener implements Listener {
}
/* GREEN THUMB CHECK */
if (Permissions.getInstance().greenThumbBlocks(player) && Herbalism.makeMossy(mat) && is.getType().equals(Material.SEEDS)) {
Herbalism.greenThumbBlocks(is, player, block);
if (inHand.getType().equals(Material.SEEDS) && BlockChecks.makeMossy(block) && Permissions.getInstance().greenThumbBlocks(player)) {
Herbalism.greenThumbBlocks(inHand, player, block);
}
/* ITEM CHECKS */
if (BlockChecks.abilityBlockCheck(mat)) {
Item.itemchecks(player);
if (BlockChecks.abilityBlockCheck(block)) {
Item.itemChecks(player);
}
/* BLAST MINING CHECK */
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
BlastMining.detonate(event, player, plugin);
}
@@ -252,10 +277,10 @@ public class PlayerListener implements Listener {
}
/* ITEM CHECKS */
Item.itemchecks(player);
Item.itemChecks(player);
/* BLAST MINING CHECK */
if (player.isSneaking() && Permissions.getInstance().blastMining(player) && is.getTypeId() == Config.getInstance().getDetonatorItemID()) {
if (player.isSneaking() && inHand.getTypeId() == Config.getInstance().getDetonatorItemID() && Permissions.getInstance().blastMining(player)) {
BlastMining.detonate(event, player, plugin);
}
@@ -265,12 +290,16 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
/* CALL OF THE WILD CHECKS */
if (player.isSneaking() && Permissions.getInstance().taming(player)) {
if (is.getType().equals(Material.RAW_FISH)) {
Taming.animalSummon(EntityType.OCELOT, player, plugin);
if (player.isSneaking()) {
Material type = inHand.getType();
if (type == Material.RAW_FISH) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonOcelot();
}
else if (is.getType().equals(Material.BONE)) {
Taming.animalSummon(EntityType.WOLF, player, plugin);
else if (type == Material.BONE) {
TamingManager tamingManager = new TamingManager(player);
tamingManager.summonWolf();
}
}
@@ -286,66 +315,61 @@ public class PlayerListener implements Listener {
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerChat(PlayerChatEvent event) {
Player player = event.getPlayer();
PlayerProfile PP = Users.getProfile(player);
boolean partyChat = PP.getPartyChatMode();
boolean adminChat = PP.getAdminChatMode();
Set<Player> recipients = event.getRecipients();
Set<Player> intendedRecipients = new HashSet<Player>();
ChatColor color = null;
if (PP.getPartyChatMode()) {
Party party = PP.getParty();
if (partyChat || adminChat) {
if (partyChat) {
if (!PP.inParty()) {
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
return;
}
color = ChatColor.GREEN;
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(player.getName(), PP.getParty(), event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return;
event.setMessage(chatEvent.getMessage());
for (Player x : Party.getInstance().getOnlineMembers(player)) {
intendedRecipients.add(x);
}
event.setFormat(color + "(" + ChatColor.WHITE + "%1$s" + color + ") %2$s");
if (party == null) {
player.sendMessage("You're not in a party, type /p to leave party chat mode."); //TODO: Use mcLocale
return;
}
if (adminChat) {
color = ChatColor.AQUA;
String partyName = party.getName();
String playerName = player.getName();
McMMOPartyChatEvent chatEvent = new McMMOPartyChatEvent(playerName, partyName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(player.getName(), event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if(chatEvent.isCancelled()) return;
event.setMessage(chatEvent.getMessage());
for (Player x : plugin.getServer().getOnlinePlayers()) {
if (x.isOp() || Permissions.getInstance().adminChat(x)) {
intendedRecipients.add(x);
}
}
event.setFormat(color + "{" + ChatColor.WHITE + "%1$s" + color + "} %2$s");
if (chatEvent.isCancelled()) {
return;
}
recipients.retainAll(intendedRecipients);
String prefix = ChatColor.GREEN + "(" + ChatColor.WHITE + playerName + ChatColor.GREEN + ") ";
plugin.getLogger().info("[P](" + partyName + ")" + "<" + playerName + "> " + chatEvent.getMessage());
for (Player member : party.getOnlineMembers()) {
member.sendMessage(prefix + chatEvent.getMessage());
}
event.setCancelled(true);
}
else if (PP.getAdminChatMode()) {
String playerName = player.getName();
McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent(playerName, event.getMessage());
plugin.getServer().getPluginManager().callEvent(chatEvent);
if (chatEvent.isCancelled()) {
return;
}
String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + playerName + ChatColor.AQUA + "} ";
plugin.getLogger().info("[A]<" + playerName + "> " + chatEvent.getMessage());
for (Player p : plugin.getServer().getOnlinePlayers()) {
if (Permissions.getInstance().adminChat(player) || player.isOp()) {
p.sendMessage(prefix + chatEvent.getMessage());
}
}
event.setCancelled(true);
}
}
// Dynamically aliasing commands need to be re-done.
// For now, using a command with an alias will send both the original command, and the mcMMO command
/**
* Monitor PlayerCommandPreprocess events.
*
@@ -354,18 +378,16 @@ public class PlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String message = event.getMessage();
if (!message.startsWith("/")) {
return;
}
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase();
if (plugin.aliasMap.containsKey(command)) {
if (command.equalsIgnoreCase(plugin.aliasMap.get(command))) {
if (plugin.commandIsAliased(lowerCaseCommand)) {
//We should find a better way to avoid string replacement where the alias is equals to the command
if (command.equals(plugin.getCommandAlias(lowerCaseCommand))) {
return;
}
event.getPlayer().chat(message.replaceFirst(command, plugin.aliasMap.get(command)));
event.setMessage(message.replace(command, plugin.getCommandAlias(lowerCaseCommand)));
}
}
}

View File

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

View File

@@ -3,22 +3,30 @@ package com.gmail.nossr50.listeners;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.getspout.spoutapi.event.input.KeyPressedEvent;
import org.getspout.spoutapi.event.screen.ButtonClickEvent;
import org.getspout.spoutapi.event.screen.ScreenCloseEvent;
import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent;
import org.getspout.spoutapi.gui.ScreenType;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.buttons.ButtonEscape;
import com.gmail.nossr50.datatypes.buttons.ButtonHUDStyle;
import com.gmail.nossr50.datatypes.buttons.ButtonPartyToggle;
import com.gmail.nossr50.datatypes.popups.PopupMMO;
import com.gmail.nossr50.spout.SpoutStuff;
import com.gmail.nossr50.util.Users;
public class SpoutListener implements Listener {
//Why do we have this here? We never use it...
mcMMO plugin = null;
private final mcMMO plugin;
public SpoutListener(mcMMO pluginx) {
plugin = pluginx;
public SpoutListener(mcMMO plugin) {
this.plugin = plugin;
}
/**
@@ -32,15 +40,106 @@ public class SpoutListener implements Listener {
PlayerProfile PPs = Users.getProfile(sPlayer);
//TODO: Add custom titles based on skills
if (Config.getInstance().getShowPowerLevelForSpout()) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl"
+ ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
if (SpoutConfig.getInstance().getShowPowerLevel()) {
sPlayer.setTitle(sPlayer.getName()+ "\n" + ChatColor.YELLOW + "P" + ChatColor.GOLD + "lvl" + ChatColor.WHITE+"." + ChatColor.GREEN + String.valueOf(PPs.getPowerLevel()));
}
if (sPlayer.isSpoutCraftEnabled()) {
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin)); //Setup Party HUD stuff
PPs.toggleSpoutEnabled();
}
}
}
/**
* Monitor Spout ButtonClick events.
*
* @param event The event to watch
*/
@EventHandler
public void onButtonClick(ButtonClickEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
PlayerProfile PP = Users.getProfile(sPlayer);
if (event.getButton() instanceof ButtonHUDStyle) {
if (SpoutStuff.playerHUDs.containsKey(sPlayer)) {
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.remove(sPlayer);
switch (PP.getHUDType()) {
case RETRO:
PP.setHUDType(HUDType.STANDARD);
break;
case STANDARD:
PP.setHUDType(HUDType.SMALL);
break;
case SMALL:
PP.setHUDType(HUDType.DISABLED);
break;
case DISABLED:
PP.setHUDType(HUDType.RETRO);
break;
default:
break;
}
SpoutStuff.playerHUDs.put(sPlayer, new HUDmmo(sPlayer, plugin));
SpoutStuff.playerScreens.get(sPlayer).updateButtons(PP);
}
}
else if (event.getButton() instanceof ButtonEscape) {
sPlayer.getMainScreen().closePopup();
}
else if (event.getButton() instanceof ButtonPartyToggle) {
PP.togglePartyHUD();
ButtonPartyToggle bpt = (ButtonPartyToggle) event.getButton();
bpt.updateText(PP);
SpoutStuff.playerHUDs.get(sPlayer).resetHUD();
SpoutStuff.playerHUDs.get(sPlayer).initializeHUD(sPlayer);
}
}
/**
* Monitor Spout ScreenClose events.
*
* @param event The event to watch
*/
@EventHandler
public void onScreenClose(ScreenCloseEvent event) {
if (event.getScreen() instanceof PopupMMO) {
SpoutStuff.playerScreens.remove(event.getPlayer());
}
}
/**
* Monitor Spout KeyPressed events.
*
* @param event The event to watch
*/
@EventHandler
public void onKeyPressedEvent(KeyPressedEvent event) {
SpoutPlayer sPlayer = event.getPlayer();
if (!sPlayer.isSpoutCraftEnabled() || sPlayer.getMainScreen().getActivePopup() != null || event.getScreenType() != ScreenType.GAME_SCREEN) {
return;
}
if (event.getKey() == SpoutStuff.keypress) {
if (!SpoutStuff.playerScreens.containsKey(sPlayer)) {
PopupMMO mmoPop = new PopupMMO(sPlayer, Users.getProfile(sPlayer), plugin);
SpoutStuff.playerScreens.put(sPlayer, mmoPop);
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
else {
sPlayer.getMainScreen().attachPopupScreen(SpoutStuff.playerScreens.get(sPlayer));
sPlayer.getMainScreen().setDirty(true);
}
}
}
}

View File

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

View File

@@ -0,0 +1,43 @@
package com.gmail.nossr50.listeners;
import java.io.File;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldSaveEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import com.gmail.nossr50.mcMMO;
public class WorldListener implements Listener {
@EventHandler
public void onWorldLoad(WorldLoadEvent event) {
File dataDir = new File(event.getWorld().getWorldFolder(), "mcmmo_data");
if(!dataDir.exists()) {
dataDir.mkdir();
}
}
@EventHandler
public void onWorldUnload(WorldUnloadEvent event) {
mcMMO.placeStore.unloadWorld(event.getWorld());
}
@EventHandler
public void onWorldSave(WorldSaveEvent event) {
mcMMO.placeStore.saveWorld(event.getWorld());
}
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
mcMMO.placeStore.chunkLoaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
}
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
mcMMO.placeStore.chunkUnloaded(event.getChunk().getX(), event.getChunk().getZ(), event.getChunk().getWorld());
}
}

View File

@@ -1,73 +1,152 @@
package com.gmail.nossr50;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.commands.spout.*;
import com.gmail.nossr50.commands.mc.*;
import com.gmail.nossr50.commands.party.*;
import com.gmail.nossr50.commands.general.*;
import com.gmail.nossr50.config.*;
import com.gmail.nossr50.runnables.*;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.locale.LocaleLoader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.commands.general.AddlevelsCommand;
import com.gmail.nossr50.commands.general.AddxpCommand;
import com.gmail.nossr50.commands.general.InspectCommand;
import com.gmail.nossr50.commands.general.McstatsCommand;
import com.gmail.nossr50.commands.general.MmoeditCommand;
import com.gmail.nossr50.commands.general.MmoupdateCommand;
import com.gmail.nossr50.commands.general.XprateCommand;
import com.gmail.nossr50.commands.mc.McabilityCommand;
import com.gmail.nossr50.commands.mc.MccCommand;
import com.gmail.nossr50.commands.mc.McgodCommand;
import com.gmail.nossr50.commands.mc.McmmoCommand;
import com.gmail.nossr50.commands.mc.McrefreshCommand;
import com.gmail.nossr50.commands.mc.McremoveCommand;
import com.gmail.nossr50.commands.mc.MctopCommand;
import com.gmail.nossr50.commands.party.ACommand;
import com.gmail.nossr50.commands.party.AcceptCommand;
import com.gmail.nossr50.commands.party.InviteCommand;
import com.gmail.nossr50.commands.party.PCommand;
import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.PtpCommand;
import com.gmail.nossr50.commands.skills.AcrobaticsCommand;
import com.gmail.nossr50.commands.skills.ArcheryCommand;
import com.gmail.nossr50.commands.skills.AxesCommand;
import com.gmail.nossr50.commands.skills.ExcavationCommand;
import com.gmail.nossr50.commands.skills.FishingCommand;
import com.gmail.nossr50.commands.skills.HerbalismCommand;
import com.gmail.nossr50.commands.skills.MiningCommand;
import com.gmail.nossr50.commands.skills.RepairCommand;
import com.gmail.nossr50.commands.skills.SwordsCommand;
import com.gmail.nossr50.commands.skills.TamingCommand;
import com.gmail.nossr50.commands.skills.UnarmedCommand;
import com.gmail.nossr50.commands.skills.WoodcuttingCommand;
import com.gmail.nossr50.commands.spout.MchudCommand;
import com.gmail.nossr50.commands.spout.XplockCommand;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.RepairConfigManager;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlocksConfig;
import com.gmail.nossr50.config.mods.CustomToolsConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.HardcoreListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.runnables.SaveTimer;
import com.gmail.nossr50.runnables.SkillMonitor;
import com.gmail.nossr50.runnables.SpoutStart;
import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.RepairManagerFactory;
import com.gmail.nossr50.skills.repair.Repairable;
import com.gmail.nossr50.util.Database;
import com.gmail.nossr50.util.Leaderboard;
import com.gmail.nossr50.util.Metrics;
import com.gmail.nossr50.util.Metrics.Graph;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.util.blockmeta.ChunkletManager;
import com.gmail.nossr50.util.blockmeta.ChunkletManagerFactory;
public class mcMMO extends JavaPlugin {
private final PlayerListener playerListener = new PlayerListener(this);
private final BlockListener blockListener = new BlockListener(this);
private final EntityListener entityListener = new EntityListener(this);
private final WorldListener worldListener = new WorldListener();
private final HardcoreListener hardcoreListener = new HardcoreListener();
public HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
public HashMap<Entity, Integer> arrowTracker = new HashMap<Entity, Integer>();
public HashMap<Integer, Player> tntTracker = new HashMap<Integer, Player>();
private HashMap<String, String> aliasMap = new HashMap<String, String>(); //Alias - Command
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
public static File versionFile;
public static Database database;
public static mcMMO p;
//Jar stuff
public static File mcmmo;
public static ChunkletManager placeStore;
public static RepairManager repairManager;
/* Jar Stuff */
public static File mcmmo;
//File Paths
public static String mainDirectory;
public static String flatFileDirectory;
public static String usersFile;
public static String leaderboardDirectory;
public static String modDirectory;
//Spout Check
public static boolean spoutEnabled;
/**
* Things to be run when the plugin is enabled.
*/
@Override
public void onEnable() {
p = this;
mcmmo = getFile();
setupFilePaths();
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
//Force the loading of config files
Config configInstance = Config.getInstance();
TreasuresConfig.getInstance();
HiddenConfig.getInstance();
if (!Config.getInstance().getUseMySQL()) {
List<Repairable> repairables = new ArrayList<Repairable>();
if (configInstance.getToolModsEnabled()) {
CustomToolsConfig.getInstance().load();
repairables.addAll(CustomToolsConfig.getInstance().getLoadedRepairables());
}
if (configInstance.getArmorModsEnabled()) {
CustomArmorConfig.getInstance().load();
repairables.addAll(CustomArmorConfig.getInstance().getLoadedRepairables());
}
if (configInstance.getBlockModsEnabled()) {
CustomBlocksConfig.getInstance().load();
}
//Load repair configs, make manager, and register them at this time
RepairConfigManager rManager = new RepairConfigManager(this);
repairables.addAll(rManager.getLoadedRepairables());
repairManager = RepairManagerFactory.getRepairManager(repairables.size());
repairManager.registerRepairables(repairables);
if (!configInstance.getUseMySQL()) {
Users.loadUsers();
}
@@ -77,11 +156,16 @@ public class mcMMO extends JavaPlugin {
pm.registerEvents(playerListener, this);
pm.registerEvents(blockListener, this);
pm.registerEvents(entityListener, this);
pm.registerEvents(worldListener, this);
PluginDescriptionFile pdfFile = this.getDescription();
if (configInstance.getHardcoreEnabled()) {
pm.registerEvents(hardcoreListener, this);
}
PluginDescriptionFile pdfFile = getDescription();
//Setup the leaderboards
if (Config.getInstance().getUseMySQL()) {
if (configInstance.getUseMySQL()) {
database = new Database(this);
database.createStructure();
}
@@ -100,7 +184,7 @@ public class mcMMO extends JavaPlugin {
//Schedule Spout Activation 1 second after start-up
scheduler.scheduleSyncDelayedTask(this, new SpoutStart(this), 20);
//Periodic save timer (Saves every 10 minutes)
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, Config.getInstance().getSaveInterval() * 1200);
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(this), 0, configInstance.getSaveInterval() * 1200);
//Regen & Cooldown timer (Runs every second)
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(this), 0, 20);
//Bleed timer (Runs every two seconds)
@@ -108,28 +192,54 @@ public class mcMMO extends JavaPlugin {
registerCommands();
if (Config.getInstance().getStatsTrackingEnabled()) {
if (configInstance.getStatsTrackingEnabled()) {
try {
Metrics metrics = new Metrics(this);
metrics.start();
Metrics metrics = new Metrics(this);
Graph graph = metrics.createGraph("Percentage of servers using timings");
if (pm.useTimings()) {
graph.addPlotter(new Metrics.Plotter("Enabled") {
@Override
public int getValue() {
return 1;
}
});
}
catch (IOException e) {
else {
graph.addPlotter(new Metrics.Plotter("Disabled") {
@Override
public int getValue() {
return 1;
}
});
}
metrics.start();
}
catch (IOException e) {
System.out.println("Failed to submit stats.");
}
}
// Get our ChunkletManager
placeStore = ChunkletManagerFactory.getChunkletManager();
for (World world : getServer().getWorlds()) {
placeStore.loadWorld(world);
}
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Player whose profile to get
* @return the PlayerProfile object
* Setup the various storage file paths
*/
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
public void setupFilePaths() {
mcmmo = getFile();
mainDirectory = getDataFolder().getPath() + File.separator;
flatFileDirectory = mainDirectory + "FlatFileStuff" + File.separator;
usersFile = flatFileDirectory + "mcmmo.users";
leaderboardDirectory = flatFileDirectory + "Leaderboards" + File.separator;
modDirectory = mainDirectory + "ModConfigs" + File.separator;
}
/**
@@ -140,33 +250,63 @@ public class mcMMO extends JavaPlugin {
* @param playerName Name of player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getPlayerProfileByName(String playerName) {
return Users.getProfileByName(playerName);
public PlayerProfile getPlayerProfile(String playerName) {
return Users.getProfile(playerName);
}
/**
* Get profile of the offline player.
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player Offline player whose profile to get
* @param player player whose profile to get
* @return the PlayerProfile object
*/
public PlayerProfile getOfflinePlayerProfile(OfflinePlayer player) {
public PlayerProfile getPlayerProfile(OfflinePlayer player) {
return Users.getProfile(player);
}
/**
* Get profile of the player.
* </br>
* This function is designed for API usage.
*
* @param player player whose profile to get
* @return the PlayerProfile object
*/
@Deprecated
public PlayerProfile getPlayerProfile(Player player) {
return Users.getProfile(player);
}
/**
* Things to be run when the plugin is disabled.
*/
@Override
public void onDisable() {
//Make sure to save player information if the server shuts down
for (PlayerProfile x : Users.getProfiles().values()) {
x.save();
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
playerProfile.save();
}
PartyManager.getInstance().saveParties();
getServer().getScheduler().cancelTasks(this); //This removes our tasks
//Save our metadata
placeStore.saveAll();
//Cleanup empty metadata stores
placeStore.cleanUp();
//Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
ZipLibrary.mcMMObackup();
}
catch (IOException e) {
getLogger().severe(e.toString());
}
this.getServer().getScheduler().cancelTasks(this); //This removes our tasks
System.out.println("mcMMO was disabled."); //How informative!
}
@@ -174,7 +314,6 @@ public class mcMMO extends JavaPlugin {
* Register the commands.
*/
private void registerCommands() {
//Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands)
//Skills commands
aliasMap.put(LocaleLoader.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics");
@@ -188,7 +327,7 @@ public class mcMMO extends JavaPlugin {
aliasMap.put(LocaleLoader.getString("Swords.SkillName").toLowerCase(), "swords");
aliasMap.put(LocaleLoader.getString("Taming.SkillName").toLowerCase(), "taming");
aliasMap.put(LocaleLoader.getString("Unarmed.SkillName").toLowerCase(), "unarmed");
aliasMap.put(LocaleLoader.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting");
aliasMap.put(LocaleLoader.getString("Woodcutting.SkillName").toLowerCase(), "woodcutting");
//Register commands
//Skills commands
@@ -205,145 +344,153 @@ public class mcMMO extends JavaPlugin {
getCommand("unarmed").setExecutor(new UnarmedCommand());
getCommand("woodcutting").setExecutor(new WoodcuttingCommand());
Config configInstance = Config.getInstance();
//mc* commands
if (Config.getInstance().getCommandMCRemoveEnabled()) {
if (configInstance.getCommandMCRemoveEnabled()) {
getCommand("mcremove").setExecutor(new McremoveCommand(this));
}
if (Config.getInstance().getCommandMCAbilityEnabled()) {
if (configInstance.getCommandMCAbilityEnabled()) {
getCommand("mcability").setExecutor(new McabilityCommand());
}
if (Config.getInstance().getCommandMCCEnabled()) {
if (configInstance.getCommandMCCEnabled()) {
getCommand("mcc").setExecutor(new MccCommand());
}
if (Config.getInstance().getCommandMCGodEnabled()) {
if (configInstance.getCommandMCGodEnabled()) {
getCommand("mcgod").setExecutor(new McgodCommand());
}
if (Config.getInstance().getCommandmcMMOEnabled()) {
if (configInstance.getCommandmcMMOEnabled()) {
getCommand("mcmmo").setExecutor(new McmmoCommand());
}
if (Config.getInstance().getCommandMCRefreshEnabled()) {
if (configInstance.getCommandMCRefreshEnabled()) {
getCommand("mcrefresh").setExecutor(new McrefreshCommand(this));
}
if (Config.getInstance().getCommandMCTopEnabled()) {
if (configInstance.getCommandMCTopEnabled()) {
getCommand("mctop").setExecutor(new MctopCommand());
}
if (Config.getInstance().getCommandMCStatsEnabled()) {
if (configInstance.getCommandMCStatsEnabled()) {
getCommand("mcstats").setExecutor(new McstatsCommand());
}
//Party commands
if (Config.getInstance().getCommandAcceptEnabled()) {
if (configInstance.getCommandAcceptEnabled()) {
getCommand("accept").setExecutor(new AcceptCommand(this));
}
if (Config.getInstance().getCommandAdminChatAEnabled()) {
if (configInstance.getCommandAdminChatAEnabled()) {
getCommand("a").setExecutor(new ACommand(this));
}
if (Config.getInstance().getCommandInviteEnabled()) {
if (configInstance.getCommandInviteEnabled()) {
getCommand("invite").setExecutor(new InviteCommand(this));
}
if (Config.getInstance().getCommandPartyEnabled()) {
if (configInstance.getCommandPartyEnabled()) {
getCommand("party").setExecutor(new PartyCommand(this));
}
if (Config.getInstance().getCommandPartyChatPEnabled()) {
if (configInstance.getCommandPartyChatPEnabled()) {
getCommand("p").setExecutor(new PCommand(this));
}
if (Config.getInstance().getCommandPTPEnabled()) {
if (configInstance.getCommandPTPEnabled()) {
getCommand("ptp").setExecutor(new PtpCommand(this));
}
//Other commands
if (Config.getInstance().getCommandAddXPEnabled()) {
if (configInstance.getCommandAddXPEnabled()) {
getCommand("addxp").setExecutor(new AddxpCommand(this));
}
if (Config.getInstance().getCommandAddLevelsEnabled()) {
if (configInstance.getCommandAddLevelsEnabled()) {
getCommand("addlevels").setExecutor(new AddlevelsCommand(this));
}
if (Config.getInstance().getCommandMmoeditEnabled()) {
getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
if (configInstance.getCommandMmoeditEnabled()) {
getCommand("mmoedit").setExecutor(new MmoeditCommand());
}
if (Config.getInstance().getCommandInspectEnabled()) {
if (configInstance.getCommandInspectEnabled()) {
getCommand("inspect").setExecutor(new InspectCommand(this));
}
if (Config.getInstance().getCommandXPRateEnabled()) {
if (configInstance.getCommandXPRateEnabled()) {
getCommand("xprate").setExecutor(new XprateCommand(this));
}
getCommand("mmoupdate").setExecutor(new MmoupdateCommand(this));
//Spout commands
if (Config.getInstance().getCommandXPLockEnabled()) {
if (configInstance.getCommandXPLockEnabled()) {
getCommand("xplock").setExecutor(new XplockCommand());
}
getCommand("mchud").setExecutor(new MchudCommand(this));
}
/*
* Boilerplate Custom Config Stuff
*/
private FileConfiguration treasuresConfig = null;
private File treasuresConfigFile = null;
/**
* Reload the Treasures.yml file.
*/
public void reloadTreasuresConfig() {
if (treasuresConfigFile == null) {
treasuresConfigFile = new File(getDataFolder(), "treasures.yml");
}
treasuresConfig = YamlConfiguration.loadConfiguration(treasuresConfigFile);
InputStream defConfigStream = getResource("treasures.yml"); // Look for defaults in the jar
if (defConfigStream != null) {
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream);
treasuresConfig.setDefaults(defConfig);
}
}
/**
* Get the Treasures config information.
* Checks to see if the alias map contains the given key.
*
* @return the configuration object for treasures.yml
* @param command The command to check
* @return true if the command is in the map, false otherwise
*/
public FileConfiguration getTreasuresConfig() {
if (treasuresConfig == null) {
reloadTreasuresConfig();
}
return treasuresConfig;
public boolean commandIsAliased(String command) {
return aliasMap.containsKey(command);
}
/**
* Save the Treasures config informtion.
* Get the alias of a given command.
*
* @param command The command to retrieve the alias of
* @return the alias of the command
*/
public void saveTreasuresConfig() {
if (treasuresConfig == null || treasuresConfigFile == null) {
return;
}
public String getCommandAlias(String command) {
return aliasMap.get(command);
}
try {
treasuresConfig.save(treasuresConfigFile);
}
catch (IOException ex) {
this.getLogger().severe("Could not save config to " + treasuresConfigFile + ex.toString());
}
/**
* Add a set of values to the TNT tracker.
*
* @param tntID The EntityID of the TNT
* @param playerName The name of the detonating player
*/
public void addToTNTTracker(int tntID, String playerName) {
tntTracker.put(tntID, playerName);
}
/**
* Check to see if a given TNT Entity is tracked.
*
* @param tntID The EntityID of the TNT
* @return true if the TNT is being tracked, false otherwise
*/
public boolean tntIsTracked(int tntID) {
return tntTracker.containsKey(tntID);
}
/**
* Get the player who detonated the TNT.
*
* @param tntID The EntityID of the TNT
* @return the Player who detonated it
*/
public Player getTNTPlayer(int tntID) {
return getServer().getPlayer(tntTracker.get(tntID));
}
/**
* Remove TNT from the tracker after it explodes.
*
* @param tntID The EntityID of the TNT
*/
public void removeFromTNTTracker(int tntID) {
tntTracker.remove(tntID);
}
}

View File

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

View File

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

View File

@@ -15,7 +15,7 @@ import com.gmail.nossr50.util.Combat;
public class BleedTimer implements Runnable {
private final static int MAX_BLEED_TICKS = 10;
private static Map<LivingEntity, Integer> bleedList = new HashMap<LivingEntity, Integer>();
private static Map<LivingEntity, Integer> bleedAddList = new HashMap<LivingEntity, Integer>();
private static List<LivingEntity> bleedRemoveList = new ArrayList<LivingEntity>();
@@ -48,13 +48,8 @@ public class BleedTimer implements Runnable {
}
//Never kill with Bleeding
if (player.getHealth() - 2 < 0) {
if (player.getHealth() - 1 > 0) {
Combat.dealDamage(player, 1);
}
}
else {
Combat.dealDamage(player, 2);
if (player.getHealth() - 1 > 0) {
Combat.dealDamage(player, 1);
}
entry.setValue(entry.getValue() - 1);
@@ -89,7 +84,7 @@ public class BleedTimer implements Runnable {
/**
* Instantly Bleed out a LivingEntity
*
*
* @param entity LivingEntity to bleed out
*/
public static void bleedOut(LivingEntity entity) {
@@ -101,7 +96,7 @@ public class BleedTimer implements Runnable {
/**
* Remove a LivingEntity from the bleedList if it is in it
*
*
* @param entity LivingEntity to remove
*/
public static void remove(LivingEntity entity) {
@@ -121,6 +116,7 @@ public class BleedTimer implements Runnable {
* Add a LivingEntity to the bleedList if it is not in it.
*
* @param entity LivingEntity to add
* @param ticks Number of bleeding ticks
*/
public static void add(LivingEntity entity, int ticks) {
int newTicks = ticks;
@@ -128,7 +124,7 @@ public class BleedTimer implements Runnable {
if (lock) {
if (bleedAddList.containsKey(entity)) {
newTicks += bleedAddList.get(entity);
if (newTicks > MAX_BLEED_TICKS) {
newTicks = MAX_BLEED_TICKS;
}
@@ -146,7 +142,7 @@ public class BleedTimer implements Runnable {
else {
if (bleedList.containsKey(entity)) {
newTicks += bleedList.get(entity);
if (newTicks > MAX_BLEED_TICKS) {
newTicks = MAX_BLEED_TICKS;
}
@@ -172,7 +168,7 @@ public class BleedTimer implements Runnable {
/**
* Check to see if a LivingEntity is in the bleedList
*
*
* @param entity LivingEntity to check if in the bleedList
* @return true if in the list, false if not
*/

View File

@@ -5,7 +5,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Skills;
public class GainXp implements Runnable {
private Player player = null;
@@ -27,7 +27,7 @@ public class GainXp implements Runnable {
@Override
public void run() {
int health = target.getHealth();
int damage = baseHealth - health;
int damage = baseHealth - health;
//May avoid negative xp, we don't know what other plugins do with the entity health
if (damage <= 0) {
@@ -39,7 +39,6 @@ public class GainXp implements Runnable {
damage += health;
}
PP.addXP(skillType, (int) (damage * baseXp));
Skills.XpCheckSkill(skillType, player);
Skills.xpProcessing(player, PP, skillType, (int) (damage * baseXp));
}
}

View File

@@ -0,0 +1,21 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.util.Users;
public class ProfileSaveTask implements Runnable {
private PlayerProfile playerProfile;
public ProfileSaveTask(PlayerProfile playerProfile) {
this.playerProfile = playerProfile;
}
@Override
public void run() {
playerProfile.save();
if (!playerProfile.getPlayer().isOnline()) {
Users.getProfiles().remove(playerProfile);
}
}
}

View File

@@ -1,20 +0,0 @@
package com.gmail.nossr50.runnables;
import com.gmail.nossr50.util.Users;
public class RemoveProfileFromMemoryTask implements Runnable {
private String playerName = null;
public RemoveProfileFromMemoryTask(String playerName) {
this.playerName = playerName;
}
@Override
public void run() {
//Check if the profile still exists (stuff like MySQL reconnection removes profiles)
if (Users.players.containsKey(playerName.toLowerCase())) {
Users.getProfileByName(playerName.toLowerCase()).save(); //We save here so players don't quit/reconnect to cause lag
Users.removeUserByName(playerName.toLowerCase());
}
}
}

View File

@@ -16,16 +16,16 @@ public class SQLReconnect implements Runnable {
@Override
public void run() {
if (Database.isConnected()) {
if (!Database.isConnected()) {
Database.connect();
if (Database.isConnected()) {
for (PlayerProfile x : Users.players.values()) {
x.save(); //Save all profiles
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
playerProfile.save(); //Save all profiles
}
Users.players.clear(); //Clear the profiles
for (Player x : plugin.getServer().getOnlinePlayers()) {
Users.addUser(x); //Add in new profiles, forcing them to 'load' again from MySQL
Users.clearUsers(); //Clear the profiles
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.addUser(player); //Add in new profiles, forcing them to 'load' again from MySQL
}
}
}

View File

@@ -1,8 +1,10 @@
package com.gmail.nossr50.runnables;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Users;
public class SaveTimer implements Runnable {
@@ -15,8 +17,14 @@ public class SaveTimer implements Runnable {
@Override
public void run() {
//All player data will be saved periodically through this
for (Player player : plugin.getServer().getOnlinePlayers()) {
Users.getProfile(player).save();
int count = 1;
BukkitScheduler bukkitScheduler = plugin.getServer().getScheduler();
for (PlayerProfile playerProfile : Users.getProfiles().values()) {
bukkitScheduler.scheduleSyncDelayedTask(plugin, new ProfileSaveTask(playerProfile), count);
count++;
}
PartyManager.getInstance().saveParties();
}
}

View File

@@ -6,7 +6,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.AbilityType;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.skills.Skills;
import com.gmail.nossr50.util.Skills;
import com.gmail.nossr50.util.Users;
public class SkillMonitor implements Runnable {

View File

@@ -4,7 +4,7 @@ import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.FileManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.SpoutConfig;
import com.gmail.nossr50.spout.SpoutStuff;
public class SpoutStart implements Runnable{
@@ -17,14 +17,15 @@ public class SpoutStart implements Runnable{
@Override
public void run() {
if (plugin.getServer().getPluginManager().getPlugin("Spout") != null) {
Config.getInstance().spoutEnabled = true;
mcMMO.spoutEnabled = true;
}
else {
Config.getInstance().spoutEnabled = false;
mcMMO.spoutEnabled = false;
}
//Spout Stuff
if (Config.getInstance().spoutEnabled) {
if (mcMMO.spoutEnabled) {
SpoutConfig.getInstance();
SpoutStuff.setupSpoutConfigs();
SpoutStuff.registerCustomEvent();
SpoutStuff.extractFiles(); //Extract source materials

View File

@@ -1,129 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Acrobatics {
private static Random random = new Random();
/**
* Check for fall damage reduction.
*
* @param player The player whose fall damage to modify
* @param event The event to check
*/
public static void acrobaticsCheck(Player player, EntityDamageEvent event) {
final int ROLL_XP_MODIFIER = 80;
final int FALL_XP_MODIFIER = 120;
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PP = Users.getProfile(player);
int acrovar = PP.getSkillLevel(SkillType.ACROBATICS);
boolean gracefulRoll = player.isSneaking();
int damage = event.getDamage();
int health = player.getHealth();
if (!Permissions.getInstance().gracefulRoll(player)) {
gracefulRoll = false;
}
if (gracefulRoll) {
acrovar = acrovar * 2;
}
if ((acrovar > MAX_BONUS_LEVEL || random.nextInt(1000) <= acrovar) && Permissions.getInstance().roll(player)) {
int threshold = 7;
if (gracefulRoll) {
threshold = threshold * 2;
}
int newDamage = damage - threshold;
if (newDamage < 0) {
newDamage = 0;
}
/* Check for death */
if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, damage * ROLL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
event.setDamage(newDamage);
if (event.getDamage() <= 0) {
event.setCancelled(true);
}
if (gracefulRoll) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
}
}
}
else if (health - damage >= 1) {
PP.addXP(SkillType.ACROBATICS, event.getDamage() * FALL_XP_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, player);
}
}
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public static void dodgeChecks(EntityDamageByEntityEvent event) {
final int DODGE_MODIFIER = 120;
final int MAX_BONUS_LEVEL = 800;
Player defender = (Player) event.getEntity();
PlayerProfile PPd = Users.getProfile(defender);
int damage = event.getDamage();
/* PARTY CHECK */
if (event.getDamager() instanceof Player) {
Player attacker = (Player) event.getDamager();
if (Party.getInstance().inSameParty(defender, attacker)) {
return;
}
}
if (Permissions.getInstance().acrobatics(defender)) {
int skillLevel = PPd.getSkillLevel(SkillType.ACROBATICS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(4000) <= skillCheck && Permissions.getInstance().dodge(defender)) {
defender.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
if (System.currentTimeMillis() >= (5000 + PPd.getRespawnATS()) && defender.getHealth() >= 1) {
PPd.addXP(SkillType.ACROBATICS, damage * DODGE_MODIFIER);
Skills.XpCheckSkill(SkillType.ACROBATICS, defender);
}
int newDamage = damage / 2;
if (newDamage <= 0) {
event.setDamage(1);
}
else {
event.setDamage(newDamage);
}
}
}
}
}

View File

@@ -1,85 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Archery {
private static Random random = new Random();
/**
* Track arrows fired for later retrieval.
*
* @param plugin mcMMO plugin instance
* @param entity Entity damaged by the arrow
* @param PPa PlayerProfile of the player firing the arrow
*/
public static void trackArrows(mcMMO plugin, Entity entity, PlayerProfile PPa) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = PPa.getSkillLevel(SkillType.ARCHERY);
if (!plugin.arrowTracker.containsKey(entity)) {
plugin.arrowTracker.put(entity, 0);
}
if (skillLevel > MAX_BONUS_LEVEL || (random.nextInt(1000) <= skillLevel)) {
plugin.arrowTracker.put(entity, 1);
}
}
/**
* Check for Daze.
*
* @param defender Defending player
* @param attacker Attacking player
*/
public static void dazeCheck(Player defender, Player attacker) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.ARCHERY);
Location loc = defender.getLocation();
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(10) > 5) {
loc.setPitch(90);
}
else {
loc.setPitch(-90);
}
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().daze(attacker)) {
defender.teleport(loc);
Combat.dealDamage(defender, 4);
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
attacker.sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}
/**
* Check for arrow retrieval.
*
* @param entity The entity hit by the arrows
* @param plugin mcMMO plugin instance
*/
public static void arrowRetrievalCheck(Entity entity, mcMMO plugin) {
if (plugin.arrowTracker.containsKey(entity)) {
Misc.mcDropItems(entity.getLocation(), new ItemStack(Material.ARROW), plugin.arrowTracker.get(entity));
}
plugin.arrowTracker.remove(entity);
}
}

View File

@@ -1,267 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.CoalType;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.sound.SoundEffect;
import org.bukkit.enchantments.Enchantment;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
public class Mining {
private static Random random = new Random();
/**
* Drop items from Mining & Blast Mining skills.
*
* @param block The block to process drops for
*/
public static void miningDrops(Block block) {
Location loc = block.getLocation();
Material type = block.getType();
ItemStack item = new ItemStack(type);
switch (type) {
case COAL_ORE:
item = new ItemStack(Material.COAL, 1, (short) 0, CoalType.COAL.getData());
Misc.mcDropItem(loc, item);
break;
case DIAMOND_ORE:
item = new ItemStack(Material.DIAMOND);
Misc.mcDropItem(loc, item);
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
item = new ItemStack(Material.REDSTONE);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItem(loc, item, 50);
break;
case GLOWSTONE:
item = new ItemStack(Material.GLOWSTONE_DUST);
Misc.mcDropItems(loc, item, 2);
Misc.mcRandomDropItems(loc, item, 50, 2);
break;
case LAPIS_ORE:
item = new ItemStack(Material.INK_SACK, 1, (short) 0, (byte) 0x4);
Misc.mcDropItems(loc, item, 4);
Misc.mcRandomDropItems(loc, item, 50, 4);
break;
case STONE:
item = new ItemStack(Material.COBBLESTONE);
Misc.mcDropItem(loc, item);
break;
default:
Misc.mcDropItem(loc, item);
break;
}
}
/**
* Award XP for Mining blocks.
*
* @param player The player to award XP to
* @param block The block to award XP for
*/
public static void miningXP(Player player, Block block) {
PlayerProfile PP = Users.getProfile(player);
Material type = block.getType();
int xp = 0;
switch (type) {
case COAL_ORE:
xp += Config.getInstance().getMiningXPCoalOre();
break;
case DIAMOND_ORE:
xp += Config.getInstance().getMiningXPDiamondOre();
break;
case ENDER_STONE:
xp += Config.getInstance().getMiningXPEndStone();
break;
case GLOWING_REDSTONE_ORE:
case REDSTONE_ORE:
xp += Config.getInstance().getMiningXPRedstoneOre();
break;
case GLOWSTONE:
xp += Config.getInstance().getMiningXPGlowstone();
break;
case GOLD_ORE:
xp += Config.getInstance().getMiningXPGoldOre();
break;
case IRON_ORE:
xp += Config.getInstance().getMiningXPIronOre();
break;
case LAPIS_ORE:
xp += Config.getInstance().getMiningXPLapisOre();
break;
case MOSSY_COBBLESTONE:
xp += Config.getInstance().getMiningXPMossyStone();
break;
case NETHERRACK:
xp += Config.getInstance().getMiningXPNetherrack();
break;
case OBSIDIAN:
xp += Config.getInstance().getMiningXPObsidian();
break;
case SANDSTONE:
xp += Config.getInstance().getMiningXPSandstone();
break;
case STONE:
xp += Config.getInstance().getMiningXPStone();
break;
default:
break;
}
PP.addXP(SkillType.MINING, xp);
Skills.XpCheckSkill(SkillType.MINING, player);
}
/**
* Process Mining block drops.
*
* @param player The player mining the block
* @param block The block being broken
*/
public static void miningBlockCheck(Player player, Block block) {
if (block.hasMetadata("mcmmoPlacedBlock")) {
return;
}
miningXP(player, block);
if (canBeSuperBroken(block.getType())) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.MINING);
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().miningDoubleDrops(player)) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
Misc.mcDropItem(block.getLocation(), new ItemStack(block.getType()));
}
else {
miningDrops(block);
}
}
}
}
/**
* Check to see if a block is broken by Super Breaker.
*
* @param type The type of Block to check
* @return true if the block would be broken by Super Breaker, false otherwise
*/
public static Boolean canBeSuperBroken(Material type) {
switch (type) {
case COAL_ORE:
case DIAMOND_ORE:
case ENDER_STONE:
case GLOWING_REDSTONE_ORE:
case GLOWSTONE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case REDSTONE_ORE:
case SANDSTONE:
case STONE:
return true;
default:
return false;
}
}
/**
* Handle the Super Breaker ability.
*
* @param player The player using the ability
* @param block The block being affected
*/
public static void SuperBreakerBlockCheck(Player player, Block block) {
Material type = block.getType();
int tier = Misc.getTier(player.getItemInHand());
int durabilityLoss = Config.getInstance().getAbilityToolDamage();
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
switch (type) {
case OBSIDIAN:
if (tier < 4) {
return;
}
durabilityLoss = durabilityLoss * 5; //Obsidian needs to do more damage than normal
/* FALL THROUGH */
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
case GOLD_ORE:
case LAPIS_ORE:
case REDSTONE_ORE:
if (tier < 3) {
return;
}
/* FALL THROUGH */
case IRON_ORE:
if (tier < 2) {
return;
}
/* FALL THROUGH */
case COAL_ORE:
case ENDER_STONE:
case GLOWSTONE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case SANDSTONE:
case STONE:
if (block.hasMetadata("mcmmoPlacedBlock")) {
return;
}
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
Skills.abilityDurabilityLoss(player.getItemInHand(), durabilityLoss);
miningBlockCheck(player, block);
if (Config.getInstance().spoutEnabled) {
SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
}
}
}
}

View File

@@ -1,492 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.spout.SpoutSounds;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
public class Repair {
private static Random random = new Random();
/**
* Handle all the item repair checks.
*
* @param player Player repairing the item
* @param is The item being repaired
*/
public static void repairCheck(Player player, ItemStack is) {
PlayerProfile PP = Users.getProfile(player);
short durabilityBefore = is.getDurability();
PlayerInventory inventory = player.getInventory();
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
if (durabilityBefore > 0 && is.getAmount() == 1) {
/*
* REPAIR ARMOR
*/
if (ItemChecks.isArmor(is) && Config.getInstance().getRepairArmorAllowed() && Permissions.getInstance().armorRepair(player)) {
if (ItemChecks.isDiamondArmor(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 6, true);
}
else if (ItemChecks.isIronArmor(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, true);
}
else if (ItemChecks.isGoldArmor(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 4, true);
}
else if (ItemChecks.isLeatherArmor(is) && inventory.contains(Config.getInstance().getRepairLeatherMaterial()) && Permissions.getInstance().leatherRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairLeatherMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else {
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
}
}
/*
* REPAIR TOOLS
*/
else if (ItemChecks.isTool(is) && Config.getInstance().getRepairToolsAllowed() && Permissions.getInstance().toolRepair(player)) {
if (ItemChecks.isStoneTool(is) && inventory.contains(Config.getInstance().getRepairStoneMaterial()) && skillLevel >= Config.getInstance().getRepairStoneLevelRequirement() && Permissions.getInstance().stoneRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStoneMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isWoodTool(is) && inventory.contains(Config.getInstance().getRepairWoodMaterial()) && Permissions.getInstance().woodRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairWoodMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else if (ItemChecks.isIronTool(is) && inventory.contains(Config.getInstance().getRepairIronMaterial()) && skillLevel >= Config.getInstance().getRepairIronLevelRequirement() && Permissions.getInstance().ironRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairIronMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isDiamondTool(is) && inventory.contains(Config.getInstance().getRepairDiamondMaterial()) && skillLevel >= Config.getInstance().getRepairDiamondLevelRequirement() && Permissions.getInstance().diamondRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairDiamondMaterial()));
xpHandler(player, PP, is, durabilityBefore, 1, true);
}
else if (ItemChecks.isGoldTool(is) && inventory.contains(Config.getInstance().getRepairGoldMaterial()) && skillLevel >= Config.getInstance().getRepairGoldLevelRequirement() && Permissions.getInstance().goldRepair(player)) {
repairItem(player, is, new ItemStack(Config.getInstance().getRepairGoldMaterial()));
xpHandler(player, PP, is, durabilityBefore, 8, true);
}
else if (ItemChecks.isStringTool(is) && inventory.contains(Config.getInstance().getRepairStringMaterial()) && skillLevel >= Config.getInstance().getRepairStringLevelRequirement() && Permissions.getInstance().stringRepair(player)){
repairItem(player, is, new ItemStack(Config.getInstance().getRepairStringMaterial()));
xpHandler(player, PP, is, durabilityBefore, 2, false);
}
else {
needMoreVespeneGas(is, player); //UNABLE TO REPAIR
}
}
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FullDurability"));
}
}
/**
* Handle the XP gain for repair events.
*
* @param player Player repairing the item
* @param PP PlayerProfile of the repairing player
* @param is Item being repaired
* @param durabilityBefore Durability of the item before repair
* @param modify Amount to modify the durability by
* @param boost True if the modifier is a boost, false if the modifier is a reduction
*/
private static void xpHandler(Player player, PlayerProfile PP, ItemStack is, short durabilityBefore, int modify, boolean boost) {
short durabilityAfter = is.getDurability();
short dif = (short) (durabilityBefore - durabilityAfter);
if (boost) {
dif = (short) (dif * modify);
}
else{
dif = (short) (dif / modify);
}
if (ItemChecks.isShovel(is)) {
dif = (short) (dif / 3);
}
else if(ItemChecks.isSword(is)) {
dif = (short) (dif / 2);
}
else if(ItemChecks.isHoe(is)) {
dif = (short) (dif / 2);
}
PP.addXP(SkillType.REPAIR, dif * 10);
Skills.XpCheckSkill(SkillType.REPAIR, player);
//CLANG CLANG
if (Config.getInstance().spoutEnabled) {
SpoutSounds.playRepairNoise(player, mcMMO.p);
}
}
/**
* Get current Arcane Forging rank.
*
* @param skillLevel The skill level of the player whose rank is being checked
* @return The player's current Arcane Forging rank
*/
public static int getArcaneForgingRank(PlayerProfile PP) {
int skillLevel = PP.getSkillLevel(SkillType.REPAIR);
if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels4()) {
return 4;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels3()) {
return 3;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels2()) {
return 2;
}
else if (skillLevel >= Config.getInstance().getArcaneForgingRankLevels1()) {
return 1;
}
else {
return 0;
}
}
/**
* Handles removing & downgrading enchants.
*
* @param player Player repairing the item
* @param is Item being repaired
*/
private static void addEnchants(Player player, ItemStack is) {
Map<Enchantment, Integer> enchants = is.getEnchantments();
if (enchants.size() == 0) {
return;
}
int rank = getArcaneForgingRank(Users.getProfile(player));
if (rank == 0 || !Permissions.getInstance().arcaneForging(player)) {
for (Enchantment x : enchants.keySet()) {
is.removeEnchantment(x);
}
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Lost"));
return;
}
boolean downgraded = false;
for (Entry<Enchantment, Integer> enchant : enchants.entrySet()) {
Enchantment enchantment = enchant.getKey();
if (random.nextInt(100) <= getEnchantChance(rank)) {
int enchantLevel = enchant.getValue();
if (Config.getInstance().getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (random.nextInt(100) <= getDowngradeChance(rank)) {
is.addEnchantment(enchantment, enchantLevel--);
downgraded = true;
}
}
}
else {
is.removeEnchantment(enchantment);
}
}
Map<Enchantment, Integer> newEnchants = is.getEnchantments();
if (newEnchants.isEmpty()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Fail"));
}
else if (downgraded || newEnchants.size() < enchants.size()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Downgrade"));
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
}
}
/**
* Gets chance of keeping enchantment during repair.
*
* @param rank Arcane Forging rank
* @return The chance of keeping the enchantment
*/
public static int getEnchantChance(int rank) {
switch (rank) {
case 4:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank4();
case 3:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank3();
case 2:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank2();
case 1:
return Config.getInstance().getArcaneForgingKeepEnchantsChanceRank1();
default:
return 0;
}
}
/**
* Gets chance of enchantment being downgraded during repair.
*
* @param rank Arcane Forging rank
* @return The chance of the enchantment being downgraded
*/
public static int getDowngradeChance(int rank) {
switch (rank) {
case 4:
return Config.getInstance().getArcaneForgingDowngradeChanceRank4();
case 3:
return Config.getInstance().getArcaneForgingDowngradeChanceRank3();
case 2:
return Config.getInstance().getArcaneForgingDowngradeChanceRank2();
case 1:
return Config.getInstance().getArcaneForgingDowngradeChanceRank1();
default:
return 100;
}
}
/**
* Computes repair bonuses.
*
* @param player The player repairing an item
* @param durability The durability of the item being repaired
* @param ramt The base amount of durability repaired to the item
* @return The final amount of durability repaired to the item
*/
private static short repairCalculate(Player player, short durability, int ramt) {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
float bonus = (float) skillLevel / 500;
bonus = (ramt * bonus);
ramt += bonus;
if (checkPlayerProcRepair(player)) {
ramt = (short) (ramt * 2);
}
durability -= ramt;
if (durability < 0) {
durability = 0;
}
return durability;
}
/**
* Gets the base durability amount to repair an item.
*
* @param is The item being repaired
* @param player The player repairing the item
* @return The final amount of durability repaired to the item
*/
private static short getRepairAmount(ItemStack is, Player player){
short maxDurability = is.getType().getMaxDurability();
int ramt = 0;
if (ItemChecks.isShovel(is)) {
ramt = maxDurability;
}
else if (ItemChecks.isHoe(is) || ItemChecks.isSword(is) || is.getType().equals(Material.SHEARS)) {
ramt = maxDurability / 2;
}
else if (ItemChecks.isAxe(is) || ItemChecks.isMiningPick(is) || ItemChecks.isStringTool(is)) {
ramt = maxDurability / 3;
}
else if (ItemChecks.isBoots(is)) {
ramt = maxDurability / 4;
}
else if (ItemChecks.isHelmet(is)) {
ramt = maxDurability / 5;
}
else if (ItemChecks.isPants(is)) {
ramt = maxDurability / 7;
}
else if (ItemChecks.isChestplate(is)) {
ramt = maxDurability / 8;
}
return repairCalculate(player, is.getDurability(), ramt);
}
/**
* Informs a player that the repair has failed.
*
* @param is The item being repaired
* @param player The player repairing the item
*/
private static void needMoreVespeneGas(ItemStack is, Player player) {
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if (is.getAmount() != 1) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.StackedItems"));
}
else {
if (ItemChecks.isDiamondTool(is) || ItemChecks.isDiamondArmor(is)) {
if (skillLevel < Config.getInstance().getRepairDiamondLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptDiamond"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.BLUE + Misc.prettyItemString(Config.getInstance().getRepairDiamondMaterial()));
}
}
else if (ItemChecks.isIronTool(is) || ItemChecks.isIronArmor(is)) {
if (skillLevel < Config.getInstance().getRepairIronLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptIron"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairIronMaterial()));
}
}
else if (ItemChecks.isGoldTool(is) || ItemChecks.isGoldArmor(is)) {
if (skillLevel < Config.getInstance().getRepairGoldLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptGold"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GOLD + Misc.prettyItemString(Config.getInstance().getRepairGoldMaterial()));
}
}
else if (ItemChecks.isStoneTool(is)) {
if (skillLevel < Config.getInstance().getRepairStoneLevelRequirement()) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.AdeptStone"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.GRAY + Misc.prettyItemString(Config.getInstance().getRepairStoneMaterial()));
}
}
else if (ItemChecks.isWoodTool(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.DARK_GREEN + Misc.prettyItemString(Config.getInstance().getRepairWoodMaterial()));
}
else if (ItemChecks.isLeatherArmor(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairLeatherMaterial()));
}
else if (ItemChecks.isStringTool(is)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore") + " " + ChatColor.YELLOW + Misc.prettyItemString(Config.getInstance().getRepairStringMaterial()));
}
}
}
/**
* Checks for Super Repair bonus.
*
* @param player The player repairing an item
* @return true if bonus granted, false otherwise
*/
public static boolean checkPlayerProcRepair(Player player) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(player).getSkillLevel(SkillType.REPAIR);
if ((skillLevel > MAX_BONUS_LEVEL || random.nextInt(1000) <= skillLevel) && Permissions.getInstance().repairBonus(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Skills.FeltEasy"));
return true;
}
return false;
}
/**
* Repairs an item.
*
* @param player The player repairing an item
* @param item The item being repaired
* @param repairMaterial The repair reagent
*/
public static void repairItem(Player player, ItemStack item, ItemStack repairMaterial) {
short initialDurability = item.getDurability();
short newDurability = getRepairAmount(item, player);
PlayerInventory inventory = player.getInventory();
McMMOPlayerRepairCheckEvent event = new McMMOPlayerRepairCheckEvent(player, (short) (initialDurability - newDurability), repairMaterial, item);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
if (repairMaterial.getType().equals(Material.WOOD)) {
removeWood(inventory);
}
else {
inventory.removeItem(repairMaterial);
}
/* Handle the enchants */
if (Config.getInstance().getArcaneForgingEnchantLossEnabled() && !Permissions.getInstance().arcaneBypass(player)) {
addEnchants(player, item);
}
item.setDurability(newDurability);
}
/**
* Handles notifications for placing an anvil.
*
* @param player The player placing the anvil
* @param anvilID The item ID of the anvil block
*/
public static void placedAnvilCheck(Player player, int anvilID) {
PlayerProfile PP = Users.getProfile(player);
if (!PP.getPlacedAnvil()) {
if (Config.getInstance().spoutEnabled) {
SpoutPlayer sPlayer = SpoutManager.getPlayer(player);
if (sPlayer.isSpoutCraftEnabled()) {
sPlayer.sendNotification("[mcMMO] Anvil Placed", "Right click to repair!", Material.getMaterial(anvilID)); //TODO: Use Locale
}
}
else {
player.sendMessage(LocaleLoader.getString("Repair.Listener.Anvil"));
}
PP.togglePlacedAnvil();
}
}
/**
* Removes wood from a player's inventory on repair. Needed due to wood having multiple possible data values.
*
* @param inventory The inventory to remove wood from
*/
private static void removeWood(PlayerInventory inventory) {
//TODO: Make this less hackish once there's a better way to do it...
int slot = inventory.first(Material.WOOD);
ItemStack item = inventory.getItem(slot);
item.setAmount(item.getAmount() - 1);
inventory.setItem(slot, item);
}
}

View File

@@ -1,110 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Combat;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Swords {
private static Random random = new Random();
/**
* Check for Bleed effect.
*
* @param attacker The attacking player
* @param entity The defending entity
* @param plugin mcMMO plugin instance
*/
public static void bleedCheck(Player attacker, LivingEntity entity, mcMMO plugin) {
if (entity instanceof Wolf) {
Wolf wolf = (Wolf) entity;
if (wolf.isTamed()) {
AnimalTamer tamer = wolf.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
if (owner == attacker || Party.getInstance().inSameParty(attacker, owner)) {
return;
}
}
}
}
final int MAX_BONUS_LEVEL = 750;
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.SWORDS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck && !entity.isDead()) {
int bleedTicks = 0;
if (skillLevel >= 750) {
bleedTicks = 3;
}
else {
bleedTicks = 2;
}
BleedTimer.add(entity, bleedTicks);
attacker.sendMessage(LocaleLoader.getString("Swords.Combat.Bleeding"));
}
}
/**
* Counter-attack entities.
*
* @param event The event to modify
*/
public static void counterAttackChecks(EntityDamageByEntityEvent event) {
Entity attacker = event.getDamager();
if (!(attacker instanceof LivingEntity)) {
return;
}
Entity target = event.getEntity();
if (target instanceof Player) {
Player defender = (Player) target;
PlayerProfile PPd = Users.getProfile(defender);
if (ItemChecks.isSword(defender.getItemInHand()) && Permissions.getInstance().counterAttack(defender)) {
final int MAX_BONUS_LEVEL = 600;
final int COUNTER_ATTACK_MODIFIER = 2;
int skillLevel = PPd.getSkillLevel(SkillType.SWORDS);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck) {
Combat.dealDamage((LivingEntity) attacker, event.getDamage() / COUNTER_ATTACK_MODIFIER);
defender.sendMessage(LocaleLoader.getString("Swords.Combat.Countered"));
if (attacker instanceof Player) {
((Player) attacker).sendMessage(LocaleLoader.getString("Swords.Combat.Counter.Hit"));
}
}
}
}
}
}

View File

@@ -1,287 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.BleedTimer;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Taming {
private static Random random = new Random();
/**
* Apply the Fast Food Service ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param theWolf The wolf using the ability
* @param event The event to modify
*/
public static void fastFoodService (PlayerProfile PPo, Wolf theWolf, EntityDamageEvent event) {
final int SKILL_ACTIVATION_LEVEL = 50;
final int ACTIVATION_CHANCE = 50;
int health = theWolf.getHealth();
int maxHealth = theWolf.getMaxHealth();
int damage = event.getDamage();
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
if (health < maxHealth) {
if (random.nextInt(100) < ACTIVATION_CHANCE) {
if (health + damage <= maxHealth) {
theWolf.setHealth(health + damage);
}
else {
theWolf.setHealth(maxHealth);
}
}
}
}
}
/**
* Apply the Sharpened Claws ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param event The event to modify
*/
public static void sharpenedClaws(PlayerProfile PPo, EntityDamageEvent event) {
final int SKILL_ACTIVATION_LEVEL = 750;
final int SHARPENED_CLAWS_BONUS = 2;
if (PPo.getSkillLevel(SkillType.TAMING) >= SKILL_ACTIVATION_LEVEL) {
event.setDamage(event.getDamage() + SHARPENED_CLAWS_BONUS);
}
}
/**
* Apply the Gore ability.
*
* @param PPo The PlayerProfile of the wolf's owner
* @param event The event to modify
* @param master The wolf's master
* @param plugin mcMMO plugin instance
*/
public static void gore(PlayerProfile PPo, EntityDamageEvent event, Player master, mcMMO plugin) {
final int GORE_MULTIPLIER = 2;
if (random.nextInt(1000) <= PPo.getSkillLevel(SkillType.TAMING)) {
Entity entity = event.getEntity();
event.setDamage(event.getDamage() * GORE_MULTIPLIER);
if (entity instanceof Player) {
((Player) entity).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
}
BleedTimer.add((LivingEntity) entity, 2);
master.sendMessage(LocaleLoader.getString("Combat.Gore"));
}
}
/**
* Get the name of a tameable animal's owner.
*
* @param beast The animal whose owner's name to get
* @return the name of the animal's owner, or "Offline Master" if the owner is offline
*/
private static String getOwnerName(Tameable beast) {
AnimalTamer tamer = beast.getOwner();
if (tamer instanceof Player) {
Player owner = (Player) tamer;
return owner.getName();
}
else {
return "Offline Master";
}
}
/**
* Prevent damage to wolves based on various skills.
*
* @param event The event to modify
*/
public static void preventDamage(EntityDamageEvent event) {
final int ENVIRONMENTALLY_AWARE_LEVEL = 100;
final int THICK_FUR_LEVEL = 250;
final int SHOCK_PROOF_LEVEL = 500;
final int THICK_FUR_MODIFIER = 2;
final int SHOCK_PROOF_MODIFIER = 6;
DamageCause cause = event.getCause();
Wolf wolf = (Wolf) event.getEntity();
Player master = (Player) wolf.getOwner();
int skillLevel = Users.getProfile(master).getSkillLevel(SkillType.TAMING);
switch (cause) {
/* Environmentally Aware */
case CONTACT:
case LAVA:
case FIRE:
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
if (event.getDamage() >= wolf.getHealth()) {
return;
}
wolf.teleport(master.getLocation());
master.sendMessage(LocaleLoader.getString("Taming.Listener.Wolf"));
}
}
break;
case FALL:
if (Permissions.getInstance().environmentallyAware(master)) {
if (skillLevel >= ENVIRONMENTALLY_AWARE_LEVEL) {
event.setCancelled(true);
}
}
break;
/* Thick Fur */
case FIRE_TICK:
if (Permissions.getInstance().thickFur(master)) {
if(skillLevel >= THICK_FUR_LEVEL) {
wolf.setFireTicks(0);
}
}
break;
case ENTITY_ATTACK:
case PROJECTILE:
if (Permissions.getInstance().thickFur(master)) {
if (skillLevel >= THICK_FUR_LEVEL) {
event.setDamage(event.getDamage() / THICK_FUR_MODIFIER);
}
}
break;
/* Shock Proof */
case ENTITY_EXPLOSION:
case BLOCK_EXPLOSION:
if (Permissions.getInstance().shockProof(master)) {
if (skillLevel >= SHOCK_PROOF_LEVEL) {
event.setDamage(event.getDamage() / SHOCK_PROOF_MODIFIER);
}
}
break;
default:
break;
}
}
/**
* Summon an animal.
*
* @param type Type of animal to summon
* @param player Player summoning the animal
*/
public static void animalSummon(EntityType type, Player player, mcMMO plugin) {
ItemStack item = player.getItemInHand();
Material summonItem = null;
int summonAmount = 0;
switch (type) {
case WOLF:
summonItem = Material.BONE;
summonAmount = Config.getInstance().getTamingCOTWWolfCost();
break;
case OCELOT:
summonItem = Material.RAW_FISH;
summonAmount = Config.getInstance().getTamingCOTWOcelotCost();
break;
default:
break;
}
if (item.getType().equals(summonItem)) {
if (item.getAmount() >= summonAmount) {
for (Entity x : player.getNearbyEntities(40, 40, 40)) {
if (x.getType().equals(type)) {
switch (type) {
case WOLF:
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Wolf"));
return;
case OCELOT:
player.sendMessage(LocaleLoader.getString("Taming.Summon.Fail.Ocelot"));
return;
default:
return;
}
}
}
LivingEntity entity = player.getWorld().spawnCreature(player.getLocation(), type);
entity.setMetadata("mcmmoSummoned", new FixedMetadataValue(plugin, true));
((Tameable) entity).setOwner(player);
if (entity.getType().equals(EntityType.OCELOT)) {
((Ocelot) entity).setCatType(Ocelot.Type.getType(1 + random.nextInt(3)));
}
if (entity.getType().equals(EntityType.WOLF)) {
entity.setHealth(entity.getMaxHealth());
}
player.setItemInHand(new ItemStack(summonItem, item.getAmount() - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
else {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore")+ " " + ChatColor.GRAY + Misc.prettyItemString(summonItem.getId()));
}
}
}
/**
* Inspect a tameable animal for details.
*
* @param event Event to modify
* @param target Animal to inspect
* @param inspector Player inspecting the animal
*/
public static void beastLore(EntityDamageByEntityEvent event, LivingEntity target, Player inspector) {
if (target instanceof Tameable) {
Tameable beast = (Tameable) target;
String message = LocaleLoader.getString("Combat.BeastLore") + " ";
int health = target.getHealth();
event.setCancelled(true);
if (beast.isTamed()) {
message = message.concat(LocaleLoader.getString("Combat.BeastLoreOwner", new Object[] {getOwnerName(beast)}) + " ");
}
message = message.concat(LocaleLoader.getString("Combat.BeastLoreHealth", new Object[] {health, target.getMaxHealth()}));
inspector.sendMessage(message);
}
}
}

View File

@@ -1,100 +0,0 @@
package com.gmail.nossr50.skills;
import java.util.Random;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class Unarmed {
private static Random random = new Random();
/**
* Apply bonus to Unarmed damage.
*
* @param PPa Profile of the attacking player
* @param event The event to modify
*/
public static void unarmedBonus(PlayerProfile PPa, EntityDamageByEntityEvent event) {
final int MAX_BONUS = 8;
int bonus = 3;
bonus += PPa.getSkillLevel(SkillType.UNARMED) / 50; //Add 1 DMG for every 50 skill levels
if (bonus > MAX_BONUS) {
bonus = MAX_BONUS;
}
event.setDamage(event.getDamage() + bonus);
}
/**
* Check for disarm.
*
* @param PPa Profile of the attacking player
* @param defender The defending player
*/
public static void disarmProcCheck(Player attacker, Player defender) {
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PPa = Users.getProfile(attacker);
int skillLevel = PPa.getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
ItemStack inHand = defender.getItemInHand();
if (!inHand.getType().equals(Material.AIR)) {
if (random.nextInt(3000) <= skillCheck && ironGrip(defender, attacker)) {
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
Misc.mcDropItem(defender.getLocation(), inHand);
defender.setItemInHand(new ItemStack(Material.AIR));
}
}
}
/**
* Check for arrow deflection.
*
* @param defender The defending player
* @param event The event to modify
*/
public static void deflectCheck(Player defender, EntityDamageByEntityEvent event) {
final int MAX_BONUS_LEVEL = 1000;
int skillLevel = Users.getProfile(defender).getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(2000) <= skillCheck && Permissions.getInstance().deflect(defender)) {
event.setCancelled(true);
defender.sendMessage(LocaleLoader.getString("Combat.ArrowDeflect"));
}
}
public static boolean ironGrip(Player defender, Player attacker) {
final int MAX_BONUS_LEVEL = 1000;
PlayerProfile PPd = Users.getProfile(defender);
int skillLevel = PPd.getSkillLevel(SkillType.UNARMED);
int skillCheck = Misc.skillCheck(skillLevel, MAX_BONUS_LEVEL);
if (random.nextInt(1000) <= skillCheck) {
defender.sendMessage(ChatColor.GREEN + "Your iron grip kept you from being disarmed!"); //TODO: Use locale
attacker.sendMessage(ChatColor.RED + "Your opponent has an iron grip!"); //TODO: Use locale
return true;
}
else {
return false;
}
}
}

View File

@@ -0,0 +1,18 @@
package com.gmail.nossr50.skills.acrobatics;
import java.util.Random;
public class Acrobatics {
public static final int DODGE_MAX_BONUS_LEVEL = 800;
public static final int DODGE_XP_MODIFIER = 120;
public static final int FALL_XP_MODIFIER = 120;
public static final int ROLL_MAX_BONUS_LEVEL = 1000;
public static final int ROLL_XP_MODIFIER = 80;
private static Random random = new Random();
public static Random getRandom() {
return random;
}
}

View File

@@ -0,0 +1,61 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public abstract class AcrobaticsEventHandler {
protected AcrobaticsManager manager;
protected Player player;
protected EntityDamageEvent event;
protected int damage;
protected int skillModifier;
protected int modifiedDamage;
protected AcrobaticsEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
this.manager = manager;
this.player = manager.getPlayer();
this.event = event;
this.damage = event.getDamage();
}
/**
* Calculate the skill modifier applied for this event.
*/
protected abstract void calculateSkillModifier();
/**
* Calculate the modified damage for this event.
*/
protected abstract void calculateModifiedDamage();
/**
* Modify the damage dealt by this event.
*/
protected abstract void modifyEventDamage();
/**
* Send the ability message for this event.
*/
protected abstract void sendAbilityMessage();
/**
* Process XP gain from this event.
*/
protected abstract void processXPGain(int xp);
/**
* Check to ensure you're not gaining XP after you die.
*
* @param damage The damage to be dealt
* @return true if the damage is fatal, false otherwise
*/
protected boolean isFatal(int damage) {
if (player.getHealth() - damage < 1) {
return true;
}
else {
return false;
}
}
}

View File

@@ -0,0 +1,75 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class AcrobaticsManager {
private Player player;
private PlayerProfile profile;
private int skillLevel;
private Permissions permissionInstance = Permissions.getInstance();
public AcrobaticsManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = profile.getSkillLevel(SkillType.ACROBATICS);
}
/**
* Check for fall damage reduction.
*
* @param event The event to check
*/
public void rollCheck(EntityDamageEvent event) {
if (!permissionInstance.roll(player)) {
return;
}
RollEventHandler eventHandler = new RollEventHandler(this, event);
if (Acrobatics.getRandom().nextInt(1000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
}
else if (!eventHandler.isFatal(event.getDamage())) {
eventHandler.processXPGain(eventHandler.damage * Acrobatics.FALL_XP_MODIFIER);
}
}
/**
* Check for dodge damage reduction.
*
* @param event The event to check
*/
public void dodgeCheck(EntityDamageEvent event) {
if (!permissionInstance.dodge(player)) {
return;
}
DodgeEventHandler eventHandler = new DodgeEventHandler(this, event);
if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
eventHandler.modifyEventDamage();
eventHandler.sendAbilityMessage();
eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
}
}
protected Player getPlayer() {
return player;
}
protected PlayerProfile getProfile() {
return profile;
}
protected int getSkillLevel() {
return skillLevel;
}
}

View File

@@ -0,0 +1,48 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Skills;
public class DodgeEventHandler extends AcrobaticsEventHandler {
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
super(manager, event);
calculateSkillModifier();
calculateModifiedDamage();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.DODGE_MAX_BONUS_LEVEL);
}
protected void calculateModifiedDamage() {
int modifiedDamage = damage / 2;
if (modifiedDamage <= 0) {
modifiedDamage = 1;
}
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
event.setDamage(modifiedDamage);
}
protected void sendAbilityMessage() {
player.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
protected void processXPGain(int xp) {
PlayerProfile profile = manager.getProfile();
if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {
Skills.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
}
}
}

View File

@@ -0,0 +1,92 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Skills;
public class RollEventHandler extends AcrobaticsEventHandler {
private boolean isGraceful;
private int damageThreshold;
protected RollEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
super(manager, event);
isGracefulRoll();
calculateSkillModifier();
calculateDamageThreshold();
calculateModifiedDamage();
}
protected void calculateSkillModifier() {
int skillModifer = manager.getSkillLevel();
if (isGraceful) {
skillModifer = skillModifer * 2;
}
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.ROLL_MAX_BONUS_LEVEL);
this.skillModifier = skillModifer;
}
protected void calculateModifiedDamage() {
int modifiedDamage = damage - damageThreshold;
if (modifiedDamage < 0) {
modifiedDamage = 0;
}
this.modifiedDamage = modifiedDamage;
}
protected void modifyEventDamage() {
event.setDamage(modifiedDamage);
if (event.getDamage() == 0) {
event.setCancelled(true);
}
}
protected void sendAbilityMessage() {
if (isGraceful) {
player.sendMessage(LocaleLoader.getString("Acrobatics.Ability.Proc"));
}
else {
player.sendMessage(LocaleLoader.getString("Acrobatics.Roll.Text"));
}
}
protected void processXPGain(int xpGain) {
Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xpGain);
}
/**
* Check if this is a graceful roll.
*/
private void isGracefulRoll() {
if (Permissions.getInstance().gracefulRoll(player)) {
this.isGraceful = player.isSneaking();
}
else {
this.isGraceful = false;
}
}
/**
* Calculate the damage threshold for this event.
*/
private void calculateDamageThreshold() {
int damageThreshold = 7;
if (isGraceful) {
damageThreshold = damageThreshold * 2;
}
this.damageThreshold = damageThreshold;
}
}

View File

@@ -0,0 +1,70 @@
package com.gmail.nossr50.skills.archery;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.util.Misc;
public class Archery {
private static Random random = new Random();
private static List<TrackedEntity> trackedEntities = new ArrayList<TrackedEntity>();
public static final int ARROW_TRACKING_MAX_BONUS_LEVEL = 1000;
public static final int BONUS_DAMAGE_INCREASE_LEVEL = 50;
public static final double BONUS_DAMAGE_INCREASE_PERCENT = 0.1D;
public static final double BONUS_DAMAGE_MAX_BONUS_PERCENTAGE = 2.0D;
public static final int DAZE_MAX_BONUS_LEVEL = 1000;
public static final int DAZE_MODIFIER = 4;
protected static void incrementTrackerValue(LivingEntity livingEntity) {
for (TrackedEntity trackedEntity : trackedEntities) {
if (trackedEntity.getLivingEntity() == livingEntity) {
trackedEntity.incrementArrowCount();
return;
}
}
//If the entity isn't tracked yet
addToTracker(livingEntity);
}
protected static void addToTracker(LivingEntity livingEntity) {
TrackedEntity trackedEntity = new TrackedEntity(livingEntity);
trackedEntity.incrementArrowCount();
trackedEntities.add(trackedEntity);
}
protected static void removeFromTracker(TrackedEntity trackedEntity) {
trackedEntities.remove(trackedEntity);
}
/**
* Check for arrow retrieval.
*
* @param entity The entity hit by the arrows
*/
public static void arrowRetrievalCheck(LivingEntity livingEntity) {
for (Iterator<TrackedEntity> it = trackedEntities.iterator() ; it.hasNext() ; ) {
TrackedEntity trackedEntity = it.next();
if (trackedEntity.getLivingEntity() == livingEntity) {
Misc.dropItems(livingEntity.getLocation(), new ItemStack(Material.ARROW), trackedEntity.getArrowCount());
it.remove();
return;
}
}
}
protected static Random getRandom() {
return random;
}
}

View File

@@ -0,0 +1,32 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.event.entity.EntityDamageEvent;
public class ArcheryBonusDamageEventHandler {
private ArcheryManager manager;
private EntityDamageEvent event;
protected double damageBonusPercent;
protected ArcheryBonusDamageEventHandler(ArcheryManager manager, EntityDamageEvent event) {
this.manager = manager;
this.event = event;
}
protected void calculateDamageBonus() {
double damageBonus = ((manager.getSkillLevel() / Archery.BONUS_DAMAGE_INCREASE_LEVEL) * Archery.BONUS_DAMAGE_INCREASE_PERCENT);
if (damageBonus > Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE) {
damageBonus = Archery.BONUS_DAMAGE_MAX_BONUS_PERCENTAGE;
}
this.damageBonusPercent = damageBonus;
}
protected void modifyEventDamage() {
int damage = event.getDamage();
int archeryBonus = (int) (damage * damageBonusPercent);
event.setDamage(damage + archeryBonus);
}
}

View File

@@ -0,0 +1,86 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ArcheryManager {
private Player player;
private PlayerProfile profile;
private int skillLevel;
private Permissions permissionsInstance;
public ArcheryManager (Player player) {
this.player = player;
this.profile = Users.getProfile(player);
this.skillLevel = profile.getSkillLevel(SkillType.ARCHERY);
this.permissionsInstance = Permissions.getInstance();
}
/**
* Track arrows fired for later retrieval.
*
* @param livingEntity Entity damaged by the arrow
*/
public void trackArrows(LivingEntity livingEntity) {
if (!permissionsInstance.trackArrows(player)) {
return;
}
ArrowTrackingEventHandler eventHandler = new ArrowTrackingEventHandler(this, livingEntity);
if (Archery.getRandom().nextInt(1000) < eventHandler.skillModifier) {
eventHandler.addToTracker();
}
}
/**
* Check for Daze.
*
* @param defender Defending player
* @param event The event to modify
*/
public void dazeCheck(Player defender, EntityDamageEvent event) {
if (!permissionsInstance.daze(player)) {
return;
}
DazeEventHandler eventHandler = new DazeEventHandler(this, event, defender);
if (Archery.getRandom().nextInt(2000) < eventHandler.skillModifier) {
eventHandler.handleDazeEffect();
eventHandler.sendAbilityMessages();
}
}
/**
* Handle archery bonus damage.
*
* @param event The event to modify.
*/
public void bonusDamage(EntityDamageEvent event) {
if (!permissionsInstance.archeryBonus(player)) {
return;
}
if (skillLevel >= Archery.BONUS_DAMAGE_INCREASE_LEVEL) {
ArcheryBonusDamageEventHandler eventHandler = new ArcheryBonusDamageEventHandler(this, event);
eventHandler.calculateDamageBonus();
eventHandler.modifyEventDamage();
}
}
protected int getSkillLevel() {
return skillLevel;
}
protected Player getPlayer() {
return player;
}
}

View File

@@ -0,0 +1,27 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.util.Misc;
public class ArrowTrackingEventHandler {
private ArcheryManager manager;
private LivingEntity entity;
protected int skillModifier;
protected ArrowTrackingEventHandler (ArcheryManager manager, LivingEntity entity) {
this.manager = manager;
this.entity = entity;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.ARROW_TRACKING_MAX_BONUS_LEVEL);
}
protected void addToTracker() {
Archery.incrementTrackerValue(entity);
}
}

View File

@@ -0,0 +1,47 @@
package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
public class DazeEventHandler {
private ArcheryManager manager;
private EntityDamageEvent event;
private Player defender;
protected int skillModifier;
protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) {
this.manager = manager;
this.event = event;
this.defender = defender;
calculateSkillModifier();
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.DAZE_MAX_BONUS_LEVEL);
}
protected void handleDazeEffect() {
Location location = defender.getLocation();
if (Archery.getRandom().nextInt(10) > 5) {
location.setPitch(90);
}
else {
location.setPitch(-90);
}
defender.teleport(location);
event.setDamage(event.getDamage() + Archery.DAZE_MODIFIER);
}
protected void sendAbilityMessages() {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
manager.getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}

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