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

Compare commits

..

271 Commits

Author SHA1 Message Date
GJ
84dce845a5 Weekly beta release. 2013-02-22 11:14:13 -05:00
GJ
0a68b82078 Fixes wolves gaining combat bonuses based on their owner's held item.
Closes #713
2013-02-22 09:53:18 -05:00
NuclearW
3dc1afde7e Add graph to see if any config values have been changed from the default, or if a server is 100% vanilla configs 2013-02-22 01:08:37 -05:00
GJ
e50eb1963f Minor typo. 2013-02-20 22:01:18 -05:00
Glitchfinder
fdd6c0a0d8 Fixing an NPE related to Spout players. 2013-02-20 21:55:52 -05:00
GJ
c589c5556b MASSIVE config overhaul - most keys are now based on the "proper" name
given to a material or entity by Bukkit.

This WILL wipe some custom values you may have set, so please verify
that your values are what you want them to be after the new config file
is generated.
2013-02-20 16:44:15 -05:00
GJ
17a85c94c6 Override toString() for upcoming config changes. Also, this ability is
"Skull Splitter," not "Skull Spliiter"
2013-02-20 13:29:41 -05:00
NuclearW
4284fe1029 Revert "Add an error message when the config.yml is outdated."
This reverts commit 3cff8aba16.

Closes #639

Signed-off-by: NuclearW <incongruency@gmail.com>
2013-02-20 13:22:52 -05:00
NuclearW
dec3c10ec1 As seen on TV: ConfigLoader v2
ConfigLoader will now read the internal and external versions of files it is loading to:
- Prune old keys in the external not in the internal
- Add new keys to the external from the internal

Additionally, while order is not presently preserved, all comments will be copied out, even for new keys.
Old keys will retain their values in the external if they differ from the internal.

Also changed the config.yml to say the version on which the config was last updated, not first generated as this will be updated as part of copying out comments.

Known issue: Extra spacing in the internal config files will not be copied out.

Closes #629
2013-02-20 13:11:06 -05:00
NuclearW
c805a48a87 Add verbose logging option and a debug method to use it.
Closes #609
2013-02-20 11:47:08 -05:00
GJ
918d81198f Cleaner way to handle per-world teleport permissions. Also provides a
nice error message now to explain WHY a player can't teleport.
2013-02-20 11:43:23 -05:00
GJ
1d87de0a3e Move update checking to it's own function. 2013-02-20 11:04:05 -05:00
GJ
fdeadde7f0 This has to be one block lower or it winds up in the sky. 2013-02-20 10:56:05 -05:00
GJ
760432fb41 Fix admin chat showing up twice in the logs. 2013-02-20 10:45:30 -05:00
GJ
240589e9ea Fix perk messages being displayed even if you have no perks. 2013-02-20 10:44:17 -05:00
GJ
400c93fb7d Clean up our particle effects a bit. 2013-02-20 10:40:47 -05:00
GJ
1bcf43db63 Better way to handle daze effect. 2013-02-20 08:49:21 -05:00
GJ
79bcd76aa0 Change ability particles due to confusion over glass-breaking sound. 2013-02-20 08:42:25 -05:00
GJ
8833ceb3b5 Added particle effect to Critical Hit. 2013-02-19 19:08:21 -05:00
GJ
ccc265edf9 Add explosion effect for Greater Impact. 2013-02-19 19:08:21 -05:00
GJ
b18a4da0d9 We don't use this anymore. 2013-02-19 19:08:21 -05:00
GJ
e956988c60 Add particle effect on Dodge. 2013-02-19 19:08:20 -05:00
Glitchfinder
1b6d66d4b0 Re-adding deprecated permissions and updating to include missing permissions containers. 2013-02-19 11:24:45 -08:00
GJ
fd47d77800 Add chat toggles for the events we have particle effects for. 2013-02-19 13:25:59 -05:00
GJ
5c76ef312f Added '/mcnotify' command to toggle ability notifications on/off 2013-02-19 13:18:27 -05:00
GJ
f189907ff8 Added visual effects for ability enabling. Also readded chat messages
for people who have particle effects disabled.
2013-02-19 13:02:08 -05:00
GJ
6e32843fb4 Add potion effect for Daze. 2013-02-19 11:01:50 -05:00
GJ
a99d6eb9f8 We don't use this one either. 2013-02-19 10:39:08 -05:00
GJ
bb37a5982e We don't use these strings anymore. 2013-02-19 10:36:50 -05:00
GJ
a43a5a0861 Don't need to save the manager anymore. 2013-02-19 10:09:29 -05:00
GJ
4ff1e79cc0 Particle effect means you can now easily see when an enemy is bleeding. 2013-02-19 09:21:44 -05:00
GJ
d28794a587 Slightly cleaner way to handle a few of our repair functions. 2013-02-19 08:34:08 -05:00
GJ
19292c8007 That's not my name. That's not my name. 2013-02-19 08:12:25 -05:00
GJ
a67dd1d9d7 One of these has to be a double if we want this modifier to work. 2013-02-19 08:03:02 -05:00
GJ
9c0f763949 We already check the block data before calling this function. 2013-02-19 01:06:06 -05:00
GJ
6571864b16 Remove unused imports. 2013-02-19 01:03:21 -05:00
GJ
701822c69f MASSIVE Permissions overhaul. Added a handful of new permissions,
renamed a few more. Changed Green Terra to handle blocks based on
perms rather than the config file.

For more details, read the diff.
2013-02-19 01:02:29 -05:00
bm01
2eab93292e Removed some shouldBeAffected calls
I'm pretty sure they aren't needed there
2013-02-19 02:20:12 +01:00
bm01
29fb8b83c2 Fixed combat exp gain when hitting a friendly wolf 2013-02-19 02:06:31 +01:00
bm01
ad68f50b14 Removed isNPCPlayer, isNPCEntity is identical 2013-02-19 01:47:05 +01:00
Glitchfinder
519485f155 Converting entity tracking to use Bukkit metadata. Should greatly reduce lag on chunk loading and unloading. 2013-02-18 16:19:31 -08:00
nossr50
45fbb47ccf Moving this check up 2013-02-18 15:28:18 -08:00
TfT_02
cf0f075acb Added an Update Checker, closes #559 2013-02-18 22:54:50 +01:00
GJ
d9aad67ca5 Fix splash potions not properly affecting the player that threw them. 2013-02-18 15:09:25 -05:00
GJ
083a89c1a3 Handle all our donor perks in one class. 2013-02-18 11:41:44 -05:00
GJ
671be42472 SkillTools, not Misc 2013-02-18 10:32:29 -05:00
GJ
add4bc24df Actually, we CAN use that check here. 2013-02-18 10:29:33 -05:00
GJ
1da1bb7218 These fit better in SkillTools. Plus, we had already duplicated one of
them.
2013-02-18 10:26:19 -05:00
GJ
d0d9527d39 These functions fit better in CombatTools. 2013-02-18 10:22:16 -05:00
GJ
c39827ed59 Don't need the same function in two places. 2013-02-18 10:11:43 -05:00
GJ
5d6a35d4ef Remove unused import. 2013-02-18 10:08:38 -05:00
GJ
0d62688343 If we cancel, should be on Highest priority. 2013-02-18 10:07:54 -05:00
GJ
80b7cc717f Move profile creation back to Login event, but only if the login is
allowed.
2013-02-18 09:57:11 -05:00
GJ
05a9c8b7e5 Make McMMOPlayerLevelUpEvent fully cancellable. 2013-02-18 08:35:52 -05:00
nossr50
e78cbcfcc8 Fixing a comment... wish I could tell jenkins not to compile :| 2013-02-17 16:12:47 -08:00
nossr50
f7b1aea7e0 Fixing mmoupdate to accomodate for party changes 2013-02-17 16:09:35 -08:00
GJ
2744fb122c isValid already checks isDead 2013-02-17 14:13:29 -05:00
GJ
77638bf56a Think we may have been adding some entities twice. 2013-02-17 12:14:20 -05:00
NuclearW
57e6e5400b nope.avi
Revert "Protect placeStore. It's ugly and still needs work."

This reverts commit 1fe182babe.
2013-02-17 10:05:35 -05:00
GJ
f2b03896e2 That wasn't supposed to be committed.... 2013-02-17 01:40:52 -05:00
GJ
8a795e6091 Don't need chance anymore. 2013-02-17 01:26:47 -05:00
GJ
946513cb66 Remove unused import. 2013-02-17 00:40:54 -05:00
GJ
1fe182babe Protect placeStore. It's ugly and still needs work. 2013-02-17 00:40:17 -05:00
bm01
f61aed9f6c Attempt to fix permanently opened region files
This line successfully closes files that are no longer tied to any
loaded chunk. It was sometimes problematic on large servers.
However, since I'm not completely sure if it doesn't provoke any data
loss or error, I've commented it out, waiting for a verification or
approval.
2013-02-17 04:16:51 +01:00
nossr50
08882e58b6 random.nextInt() has 0 inclusive, we need to add 1 2013-02-16 14:44:41 -08:00
nossr50
4c6f2da78a I guess Minecraft groups nearby itemstacks anyways... whoops 2013-02-16 14:33:17 -08:00
nossr50
3550310e5c Change randomDropItems() to give an equal chance for all results 2013-02-16 14:29:44 -08:00
bm01
cedd8da9ba Fixed Tree Feller dropping mushroom "blocks" instead of "items" 2013-02-16 23:09:19 +01:00
bm01
3cb269de4b TreeFeller.dropBlocks cleanup 2013-02-16 21:31:06 +01:00
bm01
91010f2958 Let's be consistent D: 2013-02-16 21:25:31 +01:00
bm01
f3e823997b getExperienceFromLog cleanup 2013-02-16 21:22:41 +01:00
bm01
4ae276d1d7 Fixed Tree Feller not being activated on big mushrooms 2013-02-16 21:14:23 +01:00
GJ
f6b38ab32a Added hidden.yml option for using potion-based buffs instead of
enchantment-based buffs.
2013-02-16 14:36:46 -05:00
GJ
6f96a5026b Take a player, not an item. Also avoids potential for NPE. 2013-02-16 11:34:39 -05:00
GJ
4071f259ad Handle all the buff removal in BlockDamage. Also removes the config
option for using Mining & Excavation without tools.
2013-02-16 11:28:19 -05:00
GJ
a9ed1a1850 Back to development 2013-02-16 00:15:12 -05:00
GJ
72a2e24c98 Weekly beta release.
PLEASE READ THE CHANGELOG.
2013-02-16 00:01:36 -05:00
GJ
593975a255 We don't have to pass the event anymore. 2013-02-16 00:00:24 -05:00
NuclearW
b16cc87ffb Turn off debug 2013-02-15 22:48:24 -05:00
NuclearW
c5e8b90d71 Reset events for debug 2013-02-15 22:48:24 -05:00
NuclearW
88a6326f87 Debugging for Metrics 2013-02-15 22:48:24 -05:00
NuclearW
0603ea0fc4 Version bump, for turt2live 2013-02-15 22:48:23 -05:00
NuclearW
c4aedd5323 Use convenience methods 2013-02-15 22:48:23 -05:00
NuclearW
6eb125c913 Chimera Wing Usage Tracker/Graph 2013-02-15 22:48:23 -05:00
NuclearW
704f7374d2 Chimera Wing Enabled Graph 2013-02-15 22:48:23 -05:00
NuclearW
009396cad9 Add in EMetrics 2013-02-15 22:48:23 -05:00
NuclearW
a38b7ca9fa Move metrics to a class of its own 2013-02-15 22:48:22 -05:00
NuclearW
c5daaffeb1 Change to use turt2live's MetricsExtension 2013-02-15 22:48:22 -05:00
bm01
83debde0a1 Changelog update 2013-02-16 03:45:26 +01:00
bm01
9c2ab19404 Slight greenThumbWheat cleanup 2013-02-16 03:42:56 +01:00
bm01
ef1a777180 Removed no longer needed check 2013-02-16 03:38:41 +01:00
bm01
77014b03ef No point in canceling the event
And it actually fixes the double call (see previous commit)
2013-02-16 03:36:27 +01:00
bm01
9143051d9f Run GreenThumbTimer on the current tick
It avoids onBlockBreak to be called twice (which basically launched
the task twice). I don't know what were the consequences but that
wasn't right anyway.
Also it would be better if we wouldn't have to cancel the event,
because there is a possibility that plugins like LogBlock don't have a
chance to process it.
2013-02-16 02:56:46 +01:00
bm01
f496ecf7b1 Fixed Green Thumb not checking rank 4 on wheat 2013-02-16 02:49:31 +01:00
GJ
fc3afc4340 Using PlantSize is cleaner. 2013-02-15 19:29:47 -05:00
GJ
fd138eb0b5 This was redundant was redundant 2013-02-15 19:20:42 -05:00
GJ
6d5835849f Fix issue with GreenThumb command display. 2013-02-15 19:18:43 -05:00
nossr50
800ebf5b64 Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2013-02-15 15:33:54 -08:00
nossr50
9df149c489 Huge Mushrooms now work for Tree Feller (UNTESTED) 2013-02-15 15:32:49 -08:00
shatteredbeam
efcf80899e Permissions class removal from Skillcommand 2013-02-15 14:38:51 -08:00
shatteredbeam
c1b12c027a Permissions class removed from Listeners 2013-02-15 13:32:23 -08:00
shatteredbeam
476ea80c4e Permissions class removed from mcMMOPlayer. 2013-02-15 13:21:21 -08:00
GJ
bf4d70e8be That was an incredibly stupid way to get those permissions. 2013-02-15 14:29:32 -05:00
GJ
284002bf8b No reason to String.valueOf() these. 2013-02-15 13:56:30 -05:00
GJ
b92b9c6507 Permissions must use the English names. 2013-02-15 13:42:37 -05:00
GJ
a8cfcf31ab Remove unused import 2013-02-15 13:42:37 -05:00
GJ
d14821e385 Fix a few more missing localized names. 2013-02-15 13:42:36 -05:00
GJ
5e8b036481 Need English name for the permission. 2013-02-15 13:42:34 -05:00
GJ
27ba4ff800 Make /xplock work for localized skill names. 2013-02-15 13:42:34 -05:00
shatteredbeam
c80bb45cad Inspection references (Remove Permissions class) 2013-02-15 10:41:04 -08:00
GJ
dedcf0469b Fix teh build. 2013-02-15 13:12:11 -05:00
GJ
9ec6a6d1aa Add constructor for adding multiple levels at once. Need to work out how
to handle level-ups in order for this to be properly cancelled, however.
2013-02-15 13:10:36 -05:00
GJ
1ce01d2043 This should be abstract. 2013-02-15 13:10:36 -05:00
GJ
0701169a7e Make McMMOPlayerXPGainEvent cancellable. 2013-02-15 13:10:34 -05:00
shatteredbeam
2d0cf6413e Permissions Murder 6: The quest for more money 2013-02-15 10:08:45 -08:00
T00thpick1
4cf658b629 Make mctop asynchroneous 2013-02-15 12:47:00 -05:00
t00thpick1
8d21883c20 Only try to index tables when we are connected 2013-02-15 12:30:27 -05:00
GJ
fca0847929 Squids are not made of chocolate. 2013-02-15 12:19:02 -05:00
GJ
1d19dab71d Full change to DyeColor.COLOR.getDyeData() - *REQUIRES* CB 1.4.7 2013-02-15 12:16:31 -05:00
GJ
49fe98ac57 Already locked it once. 2013-02-15 10:46:08 -05:00
TfT_02
bc9e946618 Revert removing Chimaera wing.
We've decided to keep it, for now.
2013-02-15 16:36:21 +01:00
GJ
3d3a1abf7b OfflinePlayer.getName().toString() is pointless. 2013-02-15 10:34:42 -05:00
GJ
1ef1d53fd9 Make our commands respect localized skill names. 2013-02-15 09:26:01 -05:00
GJ
0419dca385 Config files are now backed up even when running in SQL mode 2013-02-15 07:53:44 -05:00
GJ
11bd473f55 Added config option to disable automatic zip backups 2013-02-15 07:53:43 -05:00
TfT_02
5947ad5004 Fixed wrong names names displaying when using /ptp 2013-02-15 13:51:54 +01:00
GJ
894218cac9 Gotta protect this one too. 2013-02-15 07:44:27 -05:00
GJ
4ce06de18a Nicer way to handle the ConcurrentModification issue. 2013-02-15 07:40:47 -05:00
GJ
6c4ea34811 It's (not) over 5000% - fixes #683 2013-02-15 07:32:22 -05:00
TfT_02
34736836cc Fixed a bug where a new party leader wasn't appointed, after the previous party leader left 2013-02-15 13:22:31 +01:00
TfT_02
9c09c168f8 Fix a ConcurrentModificationException 2013-02-15 12:32:35 +01:00
GJ
c61e710341 Update Locale files. 2013-02-14 23:54:18 -05:00
NuclearW
63753b8197 Changelog 2013-02-14 23:28:57 -05:00
NuclearW
20f436c646 Squash alll the bugs 2013-02-14 23:27:19 -05:00
NuclearW
092b9096e6 Locale fallback 2013-02-14 23:27:03 -05:00
GJ
caa1b0d14c Duplicate code is bad, m'kay? 2013-02-14 19:02:50 -05:00
bm01
d39ff036c7 Fixed NPE when clicking outside of the inventory window 2013-02-14 23:56:09 +01:00
GJ
6702256b4c Auto-remove buff if a player tries to move the item. 2013-02-14 17:08:06 -05:00
GJ
110fbe9478 Clear buffs on /mcrefresh 2013-02-14 16:56:55 -05:00
GJ
128c24c8f6 Fix enchants hanging around due to server crash or disconnect. 2013-02-14 16:35:14 -05:00
GJ
6cc2497182 THis wasn't removing when it should have. 2013-02-14 16:29:49 -05:00
GJ
615288e635 Things in inventory can be null. 2013-02-14 16:02:42 -05:00
GJ
1b814b937b Move PlayerDeathEvent handler into main PlayerListener. Also add check
to deal with SuperBreaker enchants on death.
2013-02-14 15:53:17 -05:00
GJ
01e26f321d Fix issues with enchant-based Superbreaker implementation. 2013-02-14 14:35:53 -05:00
GJ
e8319aee81 Changed Super Breaker & Giga Drill Breaker to be an enchantment-based
boost, rather than an instabreak.
2013-02-14 13:12:15 -05:00
GJ
ca5bf0bd09 Fix possible fallthrough. 2013-02-14 11:07:41 -05:00
GJ
88b05cd5aa Fix Super Breaker not working right with custom blocks. 2013-02-14 09:39:22 -05:00
GJ
132fcb8c74 We need to get our priorities straight. 2013-02-14 09:26:05 -05:00
GJ
1492fa473f Ch-ch-ch-changes! 2013-02-14 07:44:53 -05:00
NuclearW
9bd33ab3df Introducing Block Cracker 2013-02-14 00:34:50 -05:00
NuclearW
7d826a0cdb Add permission check for green thumb effects during Green Terra ability 2013-02-14 00:21:33 -05:00
GJ
ec6fc30f47 3rd time's the charm? 2013-02-13 19:43:26 -05:00
GJ
25a54ea802 Clean up /ptp a bit more. 2013-02-13 19:29:46 -05:00
GJ
dda9c82940 Attempt to clarify the /ptp code - I don't know that this helps much. 2013-02-13 18:58:17 -05:00
GJ
55b88f0274 These belong better in SkillTools than Misc 2013-02-13 16:45:49 -05:00
GJ
f4da69a205 Fix some missing default cases and possible fall-through issues. 2013-02-13 16:34:36 -05:00
GJ
3a919f3e4c Fix improper permission making admin chat fail. 2013-02-13 15:25:49 -05:00
GJ
6cfd124804 Remove unused import. 2013-02-13 13:50:38 -05:00
GJ
0879e1f326 Fixed bug where fired arrows could raise skill levels other than Archery 2013-02-13 12:25:57 -05:00
GJ
8312570825 Fixed bug where splash potions could raise a player's unarmed level.
Fixes #678
2013-02-13 12:10:10 -05:00
bm01
7110e6ec3d Fixed invalid plugin.yml (tabs!) 2013-02-13 18:03:31 +01:00
GJ
1455a9b3a4 Fixed minor typo in locale file. 2013-02-13 11:50:07 -05:00
GJ
2ad73e9b2c Optimized our String/number conversions a bit. Also moved all
String-related util functions from Misc.java to StringUtils.java
2013-02-13 11:45:48 -05:00
GJ
b1db0d037d Fix localized versions of /skillname not working properly. Fixes #669 2013-02-13 10:32:37 -05:00
bm01
776821a988 Readded Impact damage durability cap (and fixed it) 2013-02-13 14:49:35 +01:00
GJ
1380e64c0b Added missing * perm node for mcmmmo.commands.mcmmo 2013-02-13 08:16:55 -05:00
GJ
0319e2cbff Added '/hardcore' and '/vampirism' commands for toggling these modes on
or off, along with the necessary permissions nodes.
2013-02-13 08:15:38 -05:00
GJ
7350fdb99c Remove unused import. 2013-02-12 23:21:34 -05:00
GJ
25061e7f71 Don't loop, broadcast. 2013-02-12 23:07:01 -05:00
shatteredbeam
0cd8d2b333 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2013-02-12 19:56:47 -08:00
shatteredbeam
28dca6e66f sender, not player. 2013-02-12 19:54:17 -08:00
shatteredbeam
491a70ad82 util.perms now uses player.hasPermissions() Uniformly. 2013-02-12 19:50:46 -08:00
GJ
aa0acf767b Log ALL the things! 2013-02-12 22:18:47 -05:00
GJ
e37f5e765e Forgot to send the permissions message. 2013-02-12 21:58:53 -05:00
GJ
fe1cf40bbb Get rid of unused functions. 2013-02-12 21:55:41 -05:00
shatteredbeam
9be6a7cf3b Permissions Murder 4: The quest for revenge 2013-02-12 18:33:55 -08:00
shatteredbeam
0684b1d425 Permissions murder: The Sequel. 2013-02-12 18:26:40 -08:00
shatteredbeam
12a2107601 More permissions murder. 2013-02-12 18:06:36 -08:00
shatteredbeam
163b3d19f9 Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2013-02-12 17:49:51 -08:00
shatteredbeam
15113ba7e4 SkillresetCommand.java Permission murder 2013-02-12 17:48:04 -08:00
GJ
5e9f01ac57 Fix party & admin chat not working right from console. 2013-02-12 20:38:35 -05:00
GJ
ec718f04d7 No sense in looping through all online players. 2013-02-12 20:38:35 -05:00
shatteredbeam
bb96c00cb9 Continuing Permissions Murder. 2013-02-12 17:37:34 -08:00
shatteredbeam
697cfeea64 Kill the permissions! 2013-02-12 17:31:46 -08:00
shatteredbeam
0528139c2c Merge branch 'master' of github.com:mcMMO-Dev/mcMMO 2013-02-12 17:22:51 -08:00
shatteredbeam
cbe68e7879 Import removal 2013-02-12 17:21:56 -08:00
shatteredbeam
074a798213 Kill the permissions middle man... 2013-02-12 17:16:41 -08:00
GJ
e9b016903b Removed /mcc command. Replaced with /mcmmo help.
NOTE: /mcmmo help seems to be having formatting issues currently - we're
looking into it.
2013-02-12 18:30:03 -05:00
GJ
8f4d5442b1 Better than looping. 2013-02-12 16:47:11 -05:00
GJ
2160eef1af Update plugin.yml 2013-02-12 16:26:08 -05:00
GJ
b66c5d7023 Clean up /ptp. Also fix bug where teleportation happened backwards when
accepting.
2013-02-12 16:24:17 -05:00
GJ
b21d5bdcc4 Inviting yourself is bad. 2013-02-12 15:08:07 -05:00
GJ
574770c289 Remove unused imports. 2013-02-12 15:05:23 -05:00
GJ
adda85a660 Convert /ptp to use Bukkit CommandAPI 2013-02-12 15:05:02 -05:00
GJ
92473cc56d True, not false. 2013-02-12 15:00:04 -05:00
GJ
d7e74b9fe0 That was poorly named. 2013-02-12 14:38:49 -05:00
GJ
9db2d50676 These should be under party, not skills. 2013-02-12 14:36:38 -05:00
bm01
048a979375 Minor ImpactEventHandler cleanup 2013-02-12 19:36:10 +01:00
bm01
761fb3b811 Bad copy paste 2013-02-12 19:19:13 +01:00
bm01
505d6e258f Removed no longer needed method (Misc.hasArmor) 2013-02-12 19:17:53 +01:00
bm01
9f22382506 Restored original behavior of Salvage.isSalvageable
It doesn't check for custom armors, I don't know if it's a bug or not
Added isMinecraftTool and isMinecraftArmor for clarity
2013-02-12 19:15:52 +01:00
bm01
f486492c37 For consistency with Bukkit, ItemChecks.isPants -> ItemChecks.isLeggings 2013-02-12 19:15:51 +01:00
bm01
6f1ddee0ac ItemChecks.isArmor should check for custom armors 2013-02-12 19:15:51 +01:00
bm01
2fac0170e7 Fixed Impact reducing durability of non-armor equipped blocks 2013-02-12 19:15:51 +01:00
GJ
56056797bc Check config values for exp & item sharing. 2013-02-12 12:08:04 -05:00
GJ
bbc2091b77 Aliased /party chat to work for /partychat and /party teleport to work
for /ptp
2013-02-12 12:04:37 -05:00
GJ
51493fab48 Don't pass the plugin. 2013-02-12 11:44:29 -05:00
GJ
5d693c5d8f Convert /party help to a subcommand 2013-02-12 11:42:13 -05:00
GJ
8cd9942be6 Prevent accidental overtranslation of our commands. 2013-02-12 11:37:37 -05:00
GJ
b2575c9b8f Cleanup from removal of leader checks. 2013-02-12 11:25:56 -05:00
GJ
a60a6355d2 We check the leader elsewhere. 2013-02-12 11:23:48 -05:00
GJ
6acfba1315 Use an enum to handle our subcommands. 2013-02-12 11:23:32 -05:00
GJ
ab731302e0 Remove unused imports 2013-02-12 10:42:59 -05:00
GJ
5a48d5c5f8 Convert /party info to a subcommand 2013-02-12 10:42:42 -05:00
GJ
e92c6b8f26 Convert /party rename to a subcommand 2013-02-12 09:22:57 -05:00
GJ
200ac53078 Add function to get a list of all players in a party to the API. 2013-02-12 09:22:36 -05:00
GJ
288907cfd4 Convert /party password to a subcommand. 2013-02-12 08:57:35 -05:00
GJ
c822be4a53 Add other usage string. 2013-02-12 08:39:45 -05:00
GJ
70f588cce1 Don't print usage here. 2013-02-12 01:45:56 -05:00
GJ
e5c7e81b08 No point in repeating this check over multiple classes. 2013-02-12 01:41:51 -05:00
bm01
45ebc2b89b 3% != 100% 2013-02-11 23:39:41 +01:00
GJ
76523d2988 3% != 100% - Fixes #671 2013-02-11 17:35:01 -05:00
GJ
98a64a0948 Convert /party lock & /party unlock to a subcommand. 2013-02-11 17:31:09 -05:00
GJ
2d6fb72b9d Use <>, not [] 2013-02-11 15:41:23 -05:00
GJ
e66ff53ca4 Convert /party owner to a subcommand. 2013-02-11 15:33:25 -05:00
GJ
e8ac3c812f Fix formatting. 2013-02-11 15:24:38 -05:00
GJ
a597a7d281 Add usage string. 2013-02-11 15:24:20 -05:00
GJ
1c0e392552 Convert /party disband to a subcommand 2013-02-11 15:19:41 -05:00
GJ
59a52a73bb We've got a function, might as well use it. 2013-02-11 15:17:15 -05:00
bm01
0aeff40aaa Made /party kick work on offline players 2013-02-11 14:14:43 +01:00
NuclearW
bcd8906315 Remove all spaces before newlines in config.yml 2013-02-11 03:08:03 -05:00
shatteredbeam
de9249e523 Added Global Multiplier Graph to Metrics
Added Global Curve Modifier Graph to Metrics
2013-02-10 23:29:19 -08:00
shatteredbeam
5160f5c380 Fixed build GJ broke. Silly Hat prepared. 2013-02-10 23:11:03 -08:00
GJ
5da51e78cc Change /party kick to a subcommand 2013-02-11 00:25:03 -05:00
GJ
2be57414ad Use <> not [] 2013-02-11 00:07:58 -05:00
GJ
c2293396be Fixing the rest of the issues with entities.yml 2013-02-10 15:57:55 -05:00
TfT_02
cdbc19570d Getting rid of all the snakes in the yaml 2013-02-10 09:34:32 +01:00
bm01
ccedd23342 Fixed NPE on /party join when the sender isn't in a party
Also cleaned up PartyManager.joinParty since it's no longer supposed
to create any party.
2013-02-09 16:21:13 +01:00
bm01
46b5746dcc Fixed bad player names displaying when using /party 2013-02-09 15:54:03 +01:00
bm01
97dafc45fa Fixed players not joining their parties at login 2013-02-09 15:52:09 +01:00
bm01
adf62fd332 Speeding up mcMMO startup a little 2013-02-09 15:45:41 +01:00
bm01
98bb865062 Load parties before trying to do anything with them 2013-02-09 15:42:02 +01:00
bm01
d50123085f Fixed bad parties saving 2013-02-09 15:26:41 +01:00
bm01
b628b9eb4d Attempt to fix IOOBException due getOfflinePlayer at server startup 2013-02-09 15:16:57 +01:00
bm01
317a39177b Fixed NPE on /party invite when used without a second argument 2013-02-09 14:51:36 +01:00
bm01
73924543df Fixed /party invite trying to invite "invite" 2013-02-09 14:50:03 +01:00
bm01
457754b6f1 Fixed NPE due to null itemShareMode 2013-02-09 14:35:48 +01:00
bm01
c659f8a9a9 Party now store OfflinePlayer instead of String 2013-02-09 14:34:53 +01:00
TfT_02
74df4a4fb6 Add random item share mode for parties.
Use /party itemshare random to enable random item sharing. Disable with
/party itemshare [none | false | off]
Whenever a party member picks up an item, everyone has a chance of
receiving that item instead of the player who picked it up.
2013-02-09 12:24:02 +01:00
TfT_02
b60d9032be Who knows what we will do next year,
but this minor bug has been fixed anyway :)
2013-02-09 10:59:41 +01:00
GJ
a2cbfa2668 We only need the name here, avoids NPE issues in /party create.
Fixes #655
2013-02-09 00:57:00 -05:00
GJ
340c47eebd Switch /party invite to a subcommand 2013-02-08 16:56:54 -05:00
GJ
ae5f39253e Make this work properly, finally. 2013-02-08 16:30:34 -05:00
GJ
3df5f529eb Anniversary is over for another year... 2013-02-08 16:30:34 -05:00
Glitchfinder
0fae8be816 Cleaning up minor issue with the ChunkStore. 2013-02-08 13:26:47 -08:00
Glitchfinder
f97e9bd19f Fixing an NPE with the /mcmmo command. 2013-02-08 12:23:14 -08:00
Glitchfinder
400d551295 Minor change to default permissions. 2013-02-08 12:14:59 -08:00
GJ
4957366beb Yet another stupid error. 2013-02-08 14:55:09 -05:00
GJ
27e4a2c290 This is a more applicable error message. 2013-02-08 13:28:58 -05:00
GJ
a424d36e96 This is less costly. 2013-02-08 13:27:28 -05:00
GJ
9c0518f251 Fix NPE on PartyJoin - Fixes #653 2013-02-08 13:16:12 -05:00
GJ
794071efb8 Not just for XP sharing. 2013-02-08 11:54:09 -05:00
GJ
787c4e5b73 Just in case they type it wrong. 2013-02-08 11:54:09 -05:00
GJ
33d3cd0522 Had the naming backwards, it's actually /party expshare 2013-02-08 11:54:09 -05:00
GJ
e14f8ad93c Convert /party shareexp to a subcommand 2013-02-08 11:54:08 -05:00
GJ
7a357634c7 We've already verified that they're in a party by this point. 2013-02-08 11:54:08 -05:00
GJ
ef5f72f56c Invert this check for clarity's sake. 2013-02-08 11:54:08 -05:00
GJ
ae3a95dd34 Convert /party quit to a subcommand 2013-02-08 11:54:07 -05:00
bm01
6d9db06305 Removed getSkillLevel, it doesn't belong to SkillType 2013-02-08 13:04:26 +01:00
GJ
35f243a6e6 No reason to use the SAME CODE in three different clases. 2013-02-07 23:59:02 -05:00
GJ
ea25558ac9 Back to weekly development. 2013-02-07 23:24:56 -05:00
188 changed files with 5070 additions and 4644 deletions

View File

@@ -9,6 +9,7 @@ Key:
Version 1.4.00-dev
+ Added new Child Skill - Smelting!
+ Added a version check, admins will get notified when a new version is available!
+ Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed.
+ Added config options for Hylian Luck skill
+ Added display values to Unarmed command for Iron Grip
@@ -30,6 +31,19 @@ Version 1.4.00-dev
+ Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged
+ Added the "wait" music disc to the default fishing treasures
+ Added "Chinese (Taiwan)" localization files (zh_TW)
+ Added '/hardcore' and '/vampirism' commands for toggling these modes on or off.
+ Added Block Cracker to Unarmed's Berserk, turn smooth brick into cracked smooth brick
+ Added config option to disable automatic zip backups.
+ Added particle effects for many abilities.
+ Added '/mcnotify' command to toggle ability notifications on/off
= Fixed Green Thumb on wheat not working properly at rank 4
= Fixed Green Thumb and Green Terra consuming twice the amount of seed needed
= Fixed Green Terra not also checking Green Thumb permissions
= Fixed bug where splash potions could raise a player's unarmed level
= Fixed bug where fired arrows could raise skill levels other than Archery
= Fixed /ptp telporting the target to the player, rather than the other way around.
= Fixed Impact reducing the durability of non-armor equipped blocks
= Fixed Impact reducing improperly the durability of armors (as a consequence it is now more effective)
= Fixed multiple commands not working properly on offline players
= Fixed /mmoedit not giving feedback when modifying another players stats
= Fixed the guide usage string showing up every time /skillname was called
@@ -51,9 +65,13 @@ Version 1.4.00-dev
= Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted)
= Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's.
= Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player
= Fixed /party kick not working on offline players
= Fixed a bug where party join messages weren't displayed
= Fixed a bug where a new party leader wasn't appointed, after the previous party leader left
= Fixed a bug where Disarm and Deflect had wrong values
= Fixed Magic Hunter (Fishing ability) favoring certain enchants
! Changed Green Terra blocks to be determined via permissions instead of the config file
! Config files are now backed up even when running in SQL mode
! Changed /p and /a to use /partychat and /adminchat as the default command name. The use of /p, /pc, /a, and /ac is still supported.
! We're now using Bukkit sounds instead of Spout sounds.
! It is now possible to use a negative number for Max_Level in treasures.yml to not use a maximum level, changed default file accordingly
@@ -61,6 +79,7 @@ Version 1.4.00-dev
! Changed how Berserk handles not picking up items to avoid listening to PlayerPickupItemEvent
! Moved Hylian Luck into a separate listener since it actually cancels the event and shouldn't just be on MONITOR.
! Changed how Tree Feller is handled, it should now put less stress on the CPU
! Changed Tree Feller to work on huge mushrooms
! Changed Fisherman's Diet and Farmer's Diet to use two seperate config values
! Major refactoring - please take note, this WILL break any mcMMO-related plugin not properly hooking into the API.
! Changed the way party commands work, use /party ? to check how to use the new commands
@@ -70,10 +89,13 @@ Version 1.4.00-dev
! Changed BeastLore: Now also displays offline player names
! Changed backup task to include ALL config files
! Deprecated most functions in ExperienceAPI, replaced them with identical versions that use a String for the SkillName rather than the SkillType enum values
! Changed Super Breaker & Giga Drill Breaker to be an enchantment-based boost, rather than an instabreak. Option exists in hidden.yml to change this to an potion-based buff.
! Changed locales to fall back on English when translated strings cannot be found.
- Removed Party "master/apprentice" system. Replaced with the new party XP share feature.
- Removed unused "healthbar" files from the resources
- Removed config options for disabling commands from the config.yml. This should instead be done through permissions.
- Removed Chimaera Wing
- Removed /mcc command. Replaced with /mcmmo [?|help|commands]
- Removed options to allow Mining & Excavation without a tool due to the changes to their abilities
Version 1.3.14
+ Added new Hylian Luck skill to Herbalism.

17
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.4.00-beta2</version>
<version>1.4.00-beta4</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -99,12 +99,12 @@
<configuration>
<artifactSet>
<includes>
<include>org.mcstats.bukkit:metrics</include>
<include>com.turt2live.metrics:MetricsExtension</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.mcstats</pattern>
<pattern>com.turt2live.metrics</pattern>
<shadedPattern>com.gmail.nossr50.util.mcstats</shadedPattern>
</relocation>
</relocations>
@@ -152,8 +152,8 @@
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<id>Plugin Metrics</id>
<url>http://repo.mcstats.org/content/repositories/public</url>
<id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url>
</repository>
</repositories>
<dependencies>
@@ -178,9 +178,10 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mcstats.bukkit</groupId>
<artifactId>metrics</artifactId>
<version>R6</version>
<groupId>com.turt2live.metrics</groupId>
<artifactId>MetricsExtension</artifactId>
<version>0.0.2-SNAPSHOT</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@@ -26,7 +26,7 @@ public final class AbilityAPI {
}
public static boolean skullSplitterEnabled(Player player) {
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLIITER);
return Users.getPlayer(player).getProfile().getAbilityMode(AbilityType.SKULL_SPLITTER);
}
public static boolean superBreakerEnabled(Player player) {

View File

@@ -1,7 +1,9 @@
package com.gmail.nossr50.api;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.party.Party;
@@ -69,15 +71,14 @@ public final class PartyAPI {
*/
public static void addToParty(Player player, String partyName) {
Party party = PartyManager.getParty(partyName);
String playerName = player.getName();
if (party == null) {
party = new Party();
party.setName(partyName);
party.setLeader(playerName);
party.setLeader(player.getName());
}
PartyManager.addToParty(playerName, Users.getPlayer(player), party);
PartyManager.addToParty(player, Users.getPlayer(player), party);
}
/**
@@ -88,7 +89,7 @@ public final class PartyAPI {
* @param player The player to remove
*/
public static void removeFromParty(Player player) {
PartyManager.removeFromParty(player.getName(), Users.getPlayer(player).getParty());
PartyManager.removeFromParty(player, Users.getPlayer(player).getParty());
}
/**
@@ -122,8 +123,28 @@ public final class PartyAPI {
*
* @param player The player to check
* @return all the players in the player's party
* @deprecated
*/
@Deprecated
public static List<String> getAllMembers(Player player) {
List<String> memberNames = new ArrayList<String>();
for (OfflinePlayer member : PartyManager.getAllMembers(player)) {
memberNames.add(member.getName());
}
return memberNames;
}
/**
* Get a list of all players in this player's party.
* </br>
* This function is designed for API usage.
*
* @param player The player to check
* @return all the players in the player's party
*/
public static List<OfflinePlayer> getOnlineAndOfflineMembers(Player player) {
return PartyManager.getAllMembers(player);
}

View File

@@ -10,7 +10,6 @@ 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.util.Permissions;
public final class ChatManager {
public ChatManager () {}
@@ -30,14 +29,7 @@ public final class ChatManager {
String adminMessage = chatEvent.getMessage();
for (Player otherPlayer : mcMMO.p.getServer().getOnlinePlayers()) {
if (Permissions.adminChat(otherPlayer) || otherPlayer.isOp()) {
otherPlayer.sendMessage(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage);
}
}
displayName = ChatColor.stripColor(displayName);
mcMMO.p.getLogger().info("[A]<" + displayName + "> " + adminMessage);
mcMMO.p.getServer().broadcast(LocaleLoader.getString("Commands.AdminChat.Prefix", displayName) + adminMessage, "mcmmo.chat.adminchat");
}
public static void handleAdminChat(Plugin plugin, String senderName, String message) {
@@ -65,8 +57,7 @@ public final class ChatManager {
member.sendMessage(LocaleLoader.getString("Commands.Party.Chat.Prefix", displayName) + partyMessage);
}
displayName = ChatColor.stripColor(displayName);
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + displayName + "> " + partyMessage);
mcMMO.p.getLogger().info("[P](" + partyName + ")" + "<" + ChatColor.stripColor(displayName) + "> " + partyMessage);
}
public static void handlePartyChat(Plugin plugin, Party party, String senderName, String message) {

View File

@@ -29,26 +29,29 @@ public abstract class ChatCommand implements CommandExecutor {
if (chatMode.isEnabled(mcMMOPlayer)) {
disableChatMode(sender);
return true;
}
else {
enableChatMode(sender);
}
enableChatMode(sender);
return true;
default:
if (args.length == 1) {
if (!(sender instanceof Player)) {
return false;
}
mcMMOPlayer = Users.getPlayer((Player) sender);
if (args[0].equalsIgnoreCase("on")) {
if (!(sender instanceof Player)) {
return false;
}
enableChatMode(sender);
return true;
}
if (args[0].equalsIgnoreCase("off")) {
if (!(sender instanceof Player)) {
return false;
}
disableChatMode(sender);
return true;
}

View File

@@ -12,35 +12,6 @@ import com.gmail.nossr50.util.Permissions;
public final class CommandHelper {
private CommandHelper() {}
/**
* Checks for command permissions.
*
* @param sender The command sender
* @param permission The permission to check
* @return true if the sender is a player without permissions, false otherwise
*/
public static boolean noCommandPermissions(CommandSender sender, String permission) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!Permissions.hasPermission(player, permission)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
}
return false;
}
public static boolean noCommandPermissions(Player player, String permission) {
if (!Permissions.hasPermission(player, permission)) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
return true;
}
return false;
}
public static boolean noConsoleUsage(CommandSender sender) {
if (!(sender instanceof Player)) {
sender.sendMessage(LocaleLoader.getString("Commands.NoConsole"));
@@ -61,23 +32,23 @@ public final class CommandHelper {
if (SkillTools.hasGatheringSkills(inspect)) {
display.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
if (Permissions.excavation(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.EXCAVATION)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Excavation.Listener"), profile.getSkillLevel(SkillType.EXCAVATION), profile.getSkillXpLevel(SkillType.EXCAVATION), profile.getXpToLevel(SkillType.EXCAVATION)));
}
if (Permissions.fishing(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.FISHING)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Fishing.Listener"), profile.getSkillLevel(SkillType.FISHING), profile.getSkillXpLevel(SkillType.FISHING), profile.getXpToLevel(SkillType.FISHING)));
}
if (Permissions.herbalism(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.HERBALISM)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Herbalism.Listener"), profile.getSkillLevel(SkillType.HERBALISM), profile.getSkillXpLevel(SkillType.HERBALISM), profile.getXpToLevel(SkillType.HERBALISM)));
}
if (Permissions.mining(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.MINING)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Mining.Listener"), profile.getSkillLevel(SkillType.MINING), profile.getSkillXpLevel(SkillType.MINING), profile.getXpToLevel(SkillType.MINING)));
}
if (Permissions.woodcutting(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.WOODCUTTING)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Woodcutting.Listener"), profile.getSkillLevel(SkillType.WOODCUTTING), profile.getSkillXpLevel(SkillType.WOODCUTTING), profile.getXpToLevel(SkillType.WOODCUTTING)));
}
}
@@ -98,23 +69,23 @@ public final class CommandHelper {
if (SkillTools.hasCombatSkills(inspect)) {
display.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
if (Permissions.axes(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.AXES)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Axes.Listener"), profile.getSkillLevel(SkillType.AXES), profile.getSkillXpLevel(SkillType.AXES), profile.getXpToLevel(SkillType.AXES)));
}
if (Permissions.archery(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.ARCHERY)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Archery.Listener"), profile.getSkillLevel(SkillType.ARCHERY), profile.getSkillXpLevel(SkillType.ARCHERY), profile.getXpToLevel(SkillType.ARCHERY)));
}
if (Permissions.swords(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.SWORDS)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Swords.Listener"), profile.getSkillLevel(SkillType.SWORDS), profile.getSkillXpLevel(SkillType.SWORDS), profile.getXpToLevel(SkillType.SWORDS)));
}
if (Permissions.taming(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.TAMING)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Taming.Listener"), profile.getSkillLevel(SkillType.TAMING), profile.getSkillXpLevel(SkillType.TAMING), profile.getXpToLevel(SkillType.TAMING)));
}
if (Permissions.unarmed(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.UNARMED)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Unarmed.Listener"), profile.getSkillLevel(SkillType.UNARMED), profile.getSkillXpLevel(SkillType.UNARMED), profile.getXpToLevel(SkillType.UNARMED)));
}
}
@@ -135,11 +106,11 @@ public final class CommandHelper {
if (SkillTools.hasMiscSkills(inspect)) {
display.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
if (Permissions.acrobatics(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.ACROBATICS)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
}
if (Permissions.repair(inspect)) {
if (Permissions.skillEnabled(inspect, SkillType.REPAIR)) {
display.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
}
}

View File

@@ -10,14 +10,17 @@ import com.gmail.nossr50.chat.commands.AdminChatCommand;
import com.gmail.nossr50.chat.commands.PartyChatCommand;
import com.gmail.nossr50.commands.admin.AddlevelsCommand;
import com.gmail.nossr50.commands.admin.AddxpCommand;
import com.gmail.nossr50.commands.admin.HardcoreCommand;
import com.gmail.nossr50.commands.admin.McgodCommand;
import com.gmail.nossr50.commands.admin.McrefreshCommand;
import com.gmail.nossr50.commands.admin.MmoeditCommand;
import com.gmail.nossr50.commands.admin.SkillresetCommand;
import com.gmail.nossr50.commands.admin.VampirismCommand;
import com.gmail.nossr50.commands.admin.XprateCommand;
import com.gmail.nossr50.commands.player.InspectCommand;
import com.gmail.nossr50.commands.player.McabilityCommand;
import com.gmail.nossr50.commands.player.McmmoCommand;
import com.gmail.nossr50.commands.player.McnotifyCommand;
import com.gmail.nossr50.commands.player.McrankCommand;
import com.gmail.nossr50.commands.player.McstatsCommand;
import com.gmail.nossr50.commands.player.MctopCommand;
@@ -27,6 +30,7 @@ import com.gmail.nossr50.database.commands.McremoveCommand;
import com.gmail.nossr50.database.commands.MmoupdateCommand;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.commands.PartyCommand;
import com.gmail.nossr50.party.commands.PtpCommand;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
import com.gmail.nossr50.skills.archery.ArcheryCommand;
import com.gmail.nossr50.skills.axes.AxesCommand;
@@ -39,11 +43,12 @@ import com.gmail.nossr50.skills.smelting.SmeltingCommand;
import com.gmail.nossr50.skills.swords.SwordsCommand;
import com.gmail.nossr50.skills.taming.TamingCommand;
import com.gmail.nossr50.skills.unarmed.UnarmedCommand;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingCommand;
import com.gmail.nossr50.spout.commands.MchudCommand;
import com.gmail.nossr50.spout.commands.XplockCommand;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public final class CommandRegistrationHelper {
private CommandRegistrationHelper() {};
@@ -52,12 +57,12 @@ public final class CommandRegistrationHelper {
public static void registerSkillCommands() {
for (SkillType skill : SkillType.values()) {
String commandName = skill.toString().toLowerCase();
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
String localizedName = SkillTools.getSkillName(skill);
PluginCommand command;
command = mcMMO.p.getCommand(commandName);
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", Misc.getCapitalized(localizedName)));
command.setDescription(LocaleLoader.getString("Commands.Description.Skill", StringUtils.getCapitalized(localizedName)));
command.setPermission("mcmmo.commands." + commandName);
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", localizedName));
@@ -211,10 +216,10 @@ public final class CommandRegistrationHelper {
public static void registerMcmmoCommand() {
PluginCommand command = mcMMO.p.getCommand("mcmmo");
command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo"));
command.setPermission("mcmmo.commands.mcmmo");
command.setPermission("mcmmo.commands.mcmmo.description;mcmmo.commands.mcmmo.help");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "?"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help"));
command.setExecutor(new McmmoCommand());
}
@@ -324,4 +329,43 @@ public final class CommandRegistrationHelper {
command.setPermissionMessage(permissionsMessage);
command.setExecutor(new PartyCommand());
}
public static void registerPtpCommand() {
PluginCommand command = mcMMO.p.getCommand("ptp");
command.setDescription(LocaleLoader.getString("Commands.Description.ptp"));
command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "<toggle|accept|acceptall>"));
command.setExecutor(new PtpCommand());
}
public static void registerHardcoreCommand() {
PluginCommand command = mcMMO.p.getCommand("hardcore");
command.setDescription(LocaleLoader.getString("Commands.Description.hardcore"));
command.setPermission("mcmmo.commands.hardcore;mcmmo.commands.hardcore.toggle;mcmmo.commands.hardcore.modify");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "hardcore", "[on|off]"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "hardcore", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
command.setExecutor(new HardcoreCommand());
}
public static void registerVampirismCommand() {
PluginCommand command = mcMMO.p.getCommand("vampirism");
command.setDescription(LocaleLoader.getString("Commands.Description.vampirism"));
command.setPermission("mcmmo.commands.vampirism;mcmmo.commands.vampirism.toggle;mcmmo.commands.vampirism.modify");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "vampirism", "[on|off]"));
command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "vampirism", "<" + LocaleLoader.getString("Commands.Usage.Rate") + ">"));
command.setExecutor(new VampirismCommand());
}
public static void registerMcnotifyCommand() {
PluginCommand command = mcMMO.p.getCommand("mcnotify");
command.setDescription(LocaleLoader.getString("Commands.Description.mcnotify"));
command.setPermission("mcmmo.commands.mcnotify");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcnotify"));
command.setExecutor(new McnotifyCommand());
}
}

View File

@@ -10,8 +10,8 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class AddlevelsCommand implements CommandExecutor{
@@ -20,10 +20,11 @@ public class AddlevelsCommand implements CommandExecutor{
PlayerProfile profile;
int levels;
boolean allSkills = false;
SkillType skill = null;
switch (args.length) {
case 2:
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels")) {
if (!Permissions.addlevels(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -40,11 +41,11 @@ public class AddlevelsCommand implements CommandExecutor{
return true;
}
if (!Misc.isInt(args[1])) {
if (!StringUtils.isInt(args[1])) {
return false;
}
levels = Integer.valueOf(args[1]);
levels = Integer.parseInt(args[1]);
profile = Users.getPlayer((Player) sender).getProfile();
if (allSkills) {
@@ -57,20 +58,21 @@ public class AddlevelsCommand implements CommandExecutor{
}
}
else {
profile.addLevels(SkillType.getSkill(args[0]), levels);
skill = SkillType.getSkill(args[0]);
profile.addLevels(skill, levels);
}
if (allSkills) {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[0])));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
}
return true;
case 3:
if (!Permissions.hasPermission(sender, "mcmmo.commands.addlevels.others")) {
if (!Permissions.addlevelsOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -83,12 +85,12 @@ public class AddlevelsCommand implements CommandExecutor{
return true;
}
if (!Misc.isInt(args[2])) {
if (!StringUtils.isInt(args[2])) {
return false;
}
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
levels = Integer.valueOf(args[2]);
levels = Integer.parseInt(args[2]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -109,7 +111,8 @@ public class AddlevelsCommand implements CommandExecutor{
}
}
else {
profile.addLevels(SkillType.getSkill(args[1]), levels);
skill = SkillType.getSkill(args[1]);
profile.addLevels(skill, levels);
}
profile.save(); // Since this is a temporary profile, we save it here.
@@ -129,8 +132,9 @@ public class AddlevelsCommand implements CommandExecutor{
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.1", levels));
}
else {
profile.addLevels(SkillType.getSkill(args[1]), levels);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, Misc.getCapitalized(args[1])));
skill = SkillType.getSkill(args[1]);
profile.addLevels(skill, levels);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.1", levels, SkillTools.getSkillName(skill)));
}
}
@@ -138,7 +142,7 @@ public class AddlevelsCommand implements CommandExecutor{
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
}
return true;

View File

@@ -4,14 +4,13 @@ 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.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class AddxpCommand implements CommandExecutor {
@@ -21,10 +20,11 @@ public class AddxpCommand implements CommandExecutor {
McMMOPlayer mcMMOPlayer;
PlayerProfile profile;
boolean allSkills = false;
SkillType skill = null;
switch (args.length) {
case 2:
if (!Permissions.hasPermission(sender, "mcmmo.commands.addxp")) {
if (!Permissions.addxp(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -41,11 +41,11 @@ public class AddxpCommand implements CommandExecutor {
return true;
}
if (!Misc.isInt(args[1])) {
if (!StringUtils.isInt(args[1])) {
return false;
}
xp = Integer.valueOf(args[1]);
xp = Integer.parseInt(args[1]);
mcMMOPlayer = Users.getPlayer((Player) sender);
profile = mcMMOPlayer.getProfile();
@@ -61,14 +61,16 @@ public class AddxpCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
}
else {
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[0]), xp);
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[0])));
skill = SkillType.getSkill(args[0]);
mcMMOPlayer.applyXpGain(skill, xp);
sender.sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
}
return true;
case 3:
if (!Permissions.hasPermission(sender, "mcmmo.commands.addxp.others")) {
if (!Permissions.addxpOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -81,12 +83,12 @@ public class AddxpCommand implements CommandExecutor {
return true;
}
if (!Misc.isInt(args[2])) {
if (!StringUtils.isInt(args[2])) {
return false;
}
mcMMOPlayer = Users.getPlayer(args[0]);
xp = Integer.valueOf(args[2]);
xp = Integer.parseInt(args[2]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
if (mcMMOPlayer == null) {
@@ -108,7 +110,8 @@ public class AddxpCommand implements CommandExecutor {
}
}
else {
profile.setSkillXpLevel(SkillType.getSkill(args[1]), xp);
skill = SkillType.getSkill(args[1]);
profile.setSkillXpLevel(skill, xp);
}
profile.save(); // Since this is a temporary profile, we save it here.
@@ -126,8 +129,9 @@ public class AddxpCommand implements CommandExecutor {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardAll", xp));
}
else {
mcMMOPlayer.applyXpGain(SkillType.getSkill(args[1]), xp);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, Misc.getCapitalized(args[1])));
skill = SkillType.getSkill(args[1]);
mcMMOPlayer.applyXpGain(skill, xp);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.addxp.AwardSkill", xp, SkillTools.getSkillName(skill)));
}
}
@@ -135,7 +139,7 @@ public class AddxpCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", Misc.getCapitalized(args[1]), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardSkill.2", SkillTools.getSkillName(skill), args[0]));
}
return true;

View File

@@ -0,0 +1,86 @@
package com.gmail.nossr50.commands.admin;
import java.text.DecimalFormat;
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.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public class HardcoreCommand implements CommandExecutor{
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (Config.getInstance().getHardcoreEnabled()) {
disableHardcore();
}
else {
enableHardcore();
}
return true;
case 1:
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enableHardcore();
return true;
}
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
if (!Permissions.hardcoreToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
disableHardcore();
return true;
}
if (!StringUtils.isDouble(args[0])) {
return false;
}
if (!Permissions.hardcoreModify(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
DecimalFormat percent = new DecimalFormat("##0.00%");
double newPercent = Double.parseDouble(args[0]);
Config.getInstance().setHardcoreDeathStatPenaltyPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Hardcore.PercentageChanged", percent.format(newPercent / 100D)));
return true;
default:
return false;
}
}
private void disableHardcore() {
Config.getInstance().setHardcoreEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Disabled"));
}
private void enableHardcore() {
Config.getInstance().setHardcoreEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Enabled"));
}
}

View File

@@ -18,7 +18,7 @@ public class McgodCommand implements CommandExecutor {
switch (args.length) {
case 0:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod")) {
if (!Permissions.mcgod(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -45,7 +45,7 @@ public class McgodCommand implements CommandExecutor {
return true;
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
if (!Permissions.mcgodOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}

View File

@@ -18,7 +18,7 @@ public class McrefreshCommand implements CommandExecutor {
switch (args.length) {
case 0:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh")) {
if (!Permissions.mcrefresh(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -38,7 +38,7 @@ public class McrefreshCommand implements CommandExecutor {
return true;
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrefresh.others")) {
if (!Permissions.mcrefreshOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}

View File

@@ -10,8 +10,8 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class MmoeditCommand implements CommandExecutor {
@@ -20,10 +20,11 @@ public class MmoeditCommand implements CommandExecutor {
PlayerProfile profile;
int newValue;
boolean allSkills = false;
SkillType skill = null;
switch (args.length) {
case 2:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mmoedit")) {
if (!Permissions.mmoedit(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -40,11 +41,11 @@ public class MmoeditCommand implements CommandExecutor {
return true;
}
if (!Misc.isInt(args[1])) {
if (!StringUtils.isInt(args[1])) {
return false;
}
newValue = Integer.valueOf(args[1]);
newValue = Integer.parseInt(args[1]);
profile = Users.getPlayer((Player) sender).getProfile();
if (allSkills) {
@@ -59,14 +60,15 @@ public class MmoeditCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
}
else {
profile.modifySkill(SkillType.getSkill(args[0]), newValue);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[0]), newValue));
skill = SkillType.getSkill(args[0]);
profile.modifySkill(skill, newValue);
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
}
return true;
case 3:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mmoedit.others")) {
if (!Permissions.mmoeditOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -79,11 +81,11 @@ public class MmoeditCommand implements CommandExecutor {
return true;
}
if (!Misc.isInt(args[2])) {
if (!StringUtils.isInt(args[2])) {
return false;
}
newValue = Integer.valueOf(args[2]);
newValue = Integer.parseInt(args[2]);
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
@@ -105,7 +107,8 @@ public class MmoeditCommand implements CommandExecutor {
}
}
else {
profile.modifySkill(SkillType.getSkill(args[1]), newValue);
skill = SkillType.getSkill(args[1]);
profile.modifySkill(skill, newValue);
}
profile.save(); // Since this is a temporary profile, we save it here.
@@ -125,8 +128,9 @@ public class MmoeditCommand implements CommandExecutor {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.AllSkills.1", newValue));
}
else {
profile.modifySkill(SkillType.getSkill(args[1]), newValue);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", Misc.getCapitalized(args[1]), newValue));
skill = SkillType.getSkill(args[1]);
profile.modifySkill(skill, newValue);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.1", SkillTools.getSkillName(skill), newValue));
}
}
@@ -134,7 +138,7 @@ public class MmoeditCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", SkillTools.getSkillName(skill), args[0]));
}
return true;

View File

@@ -10,7 +10,6 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
@@ -19,10 +18,12 @@ public class SkillresetCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
PlayerProfile profile;
boolean allSkills = false;
SkillType skill = null;
String skillName = "";
switch (args.length) {
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset")) {
if (!Permissions.skillreset(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -39,30 +40,16 @@ public class SkillresetCommand implements CommandExecutor {
return true;
}
profile = Users.getPlayer((Player) sender).getProfile();
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
if (!Permissions.skillreset(sender, skillType)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
}
else {
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset." + args[0].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
profile = Users.getPlayer((Player) sender).getProfile();
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
@@ -72,14 +59,22 @@ public class SkillresetCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
else {
profile.modifySkill(SkillType.getSkill(args[0]), 0);
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[0])));
skill = SkillType.getSkill(args[0]);
skillName = SkillTools.getSkillName(skill);
if (!Permissions.skillreset(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
profile.modifySkill(skill, 0);
sender.sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
}
return true;
case 2:
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others")) {
if (!Permissions.skillresetOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -92,20 +87,11 @@ public class SkillresetCommand implements CommandExecutor {
return true;
}
if (allSkills) {
for (SkillType skillType : SkillType.values()) {
if (skillType.isChildSkill()) {
continue;
}
if (!allSkills) {
skill = SkillType.getSkill(args[1]);
skillName = SkillTools.getSkillName(skill);
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + args[1].toLowerCase())) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
}
}
else {
if (!Permissions.hasPermission(sender, "mcmmo.commands.skillreset.others." + args[1].toLowerCase())) {
if (!Permissions.skillresetOthers(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -128,11 +114,16 @@ public class SkillresetCommand implements CommandExecutor {
continue;
}
if (!Permissions.skillresetOthers(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
continue;
}
profile.modifySkill(skillType, 0);
}
}
else {
profile.modifySkill(SkillType.getSkill(args[1]), 0);
profile.modifySkill(skill, 0);
}
profile.save(); // Since this is a temporary profile, we save it here.
@@ -146,14 +137,19 @@ public class SkillresetCommand implements CommandExecutor {
continue;
}
if (!Permissions.skillresetOthers(sender, skill)) {
sender.sendMessage(command.getPermissionMessage());
continue;
}
profile.modifySkill(skillType, 0);
}
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.All"));
}
else {
profile.modifySkill(SkillType.getSkill(args[1]), 0);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", Misc.getCapitalized(args[1])));
profile.modifySkill(skill, 0);
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Reset.Single", skillName));
}
}
@@ -161,7 +157,7 @@ public class SkillresetCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.addlevels.AwardAll.2", args[0]));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", Misc.getCapitalized(args[1]), args[0]));
sender.sendMessage(LocaleLoader.getString("Commands.mmoedit.Modified.2", skillName, args[0]));
}
return true;

View File

@@ -0,0 +1,91 @@
package com.gmail.nossr50.commands.admin;
import java.text.DecimalFormat;
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.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public class VampirismCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getHardcoreEnabled()) {
sender.sendMessage(LocaleLoader.getString("Hardcore.Disabled"));
return true;
}
switch (args.length) {
case 0:
if (!Permissions.vampirismToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (Config.getInstance().getHardcoreVampirismEnabled()) {
disableVampirism();
}
else {
enableVampirism();
}
return true;
case 1:
if (args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("true") || args[0].equalsIgnoreCase("enabled")) {
if (!Permissions.vampirismToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
enableVampirism();
return true;
}
if (args[0].equalsIgnoreCase("off") || args[0].equalsIgnoreCase("false") || args[0].equalsIgnoreCase("disabled")) {
if (!Permissions.vampirismToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
disableVampirism();
return true;
}
if (!StringUtils.isDouble(args[0])) {
return false;
}
if (!Permissions.vampirismModify(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
DecimalFormat percent = new DecimalFormat("##0.00%");
double newPercent = Double.parseDouble(args[0]);
Config.getInstance().setHardcoreVampirismStatLeechPercentage(newPercent);
sender.sendMessage(LocaleLoader.getString("Vampirism.PercentageChanged", percent.format(newPercent / 100D)));
return true;
default:
return false;
}
}
private void disableVampirism() {
Config.getInstance().setHardcoreVampirismEnabled(false);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Disabled"));
}
private void enableVampirism() {
Config.getInstance().setHardcoreVampirismEnabled(true);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Vampirism.Enabled"));
}
}

View File

@@ -3,13 +3,12 @@ package com.gmail.nossr50.commands.admin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public class XprateCommand implements CommandExecutor {
private static double originalRate = Config.getInstance().getExperienceGainsGlobalMultiplier();
@@ -22,16 +21,13 @@ public class XprateCommand implements CommandExecutor {
return false;
}
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.reset")) {
if (!Permissions.xprateReset(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (mcMMO.p.isXPEventEnabled()) {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
player.sendMessage(LocaleLoader.getString("Commands.xprate.over"));
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.over"));
mcMMO.p.toggleXpEventEnabled();
}
@@ -39,11 +35,11 @@ public class XprateCommand implements CommandExecutor {
return true;
case 2:
if (!Misc.isInt(args[0])) {
if (!StringUtils.isInt(args[0])) {
return false;
}
if (!Permissions.hasPermission(sender, "mcmmo.commands.xprate.set")) {
if (!Permissions.xprateSet(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -53,14 +49,12 @@ public class XprateCommand implements CommandExecutor {
}
mcMMO.p.setXPEventEnabled(Boolean.valueOf(args[1]));
int newXpRate = Misc.getInt(args[0]);
int newXpRate = Integer.parseInt(args[0]);
Config.getInstance().setExperienceGainsGlobalMultiplier(newXpRate);
if (mcMMO.p.isXPEventEnabled()) {
for (Player player : mcMMO.p.getServer().getOnlinePlayers()) {
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.0"));
player.sendMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
}
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.0"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.xprate.started.1", newXpRate));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.xprate.modified", newXpRate));

View File

@@ -21,11 +21,6 @@ public class InspectCommand implements CommandExecutor {
switch (args.length) {
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.inspect")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
@@ -37,7 +32,8 @@ public class InspectCommand implements CommandExecutor {
return true;
}
if (sender instanceof Player && !Permissions.inspectOffline((Player) sender)) {
// TODO: Why do we care if this is a player?
if (sender instanceof Player && !Permissions.inspectOffline(sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}

View File

@@ -18,7 +18,7 @@ public class McabilityCommand implements CommandExecutor {
switch (args.length) {
case 0:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcability")) {
if (!Permissions.mcability(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -36,7 +36,7 @@ public class McabilityCommand implements CommandExecutor {
return true;
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcability.others")) {
if (!Permissions.mcabilityOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}

View File

@@ -1,79 +0,0 @@
package com.gmail.nossr50.commands.player;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Permissions;
//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands.
public class MccCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcc")) {
return true;
}
Player player = (Player) sender;
player.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
if (Permissions.party(player)) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
player.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
player.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
player.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.partyChat(player)) {
player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle"));
}
player.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
player.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.partyTeleport(player)) {
player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
player.sendMessage(LocaleLoader.getString("Commands.Other"));
player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.skillReset(player)) {
player.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
if (Permissions.mcAbility(player)) {
player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.adminChat(player)) {
player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.inspect(player)) {
player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mmoedit(player)) {
player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (Permissions.mcgod(player)) {
player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
}
player.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
player.sendMessage("/mcmmo " + LocaleLoader.getString("Commands.ModDescription"));
return true;
}
}

View File

@@ -10,13 +10,20 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Anniversary;
import com.gmail.nossr50.party.commands.PartySubcommandType;
import com.gmail.nossr50.util.Permissions;
public class McmmoCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0 || (args.length == 1 && args[0].equals("?"))) {
switch (args.length) {
case 0:
if (!Permissions.mcmmoDescription(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
String description = LocaleLoader.getString("mcMMO.Description");
String[] mcSplit = description.split(",");
sender.sendMessage(mcSplit);
@@ -32,11 +39,76 @@ public class McmmoCommand implements CommandExecutor {
}
sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion()));
Anniversary.anniversaryCheck(sender);
return true;
case 1:
if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) {
if (!Permissions.mcmmoHelp(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header"));
displayPartyCommands(sender);
displayOtherCommands(sender);
}
return true;
default:
return false;
}
}
private void displayPartyCommands(CommandSender sender) {
if (Permissions.party(sender)) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands"));
sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1"));
sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2"));
sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit"));
if (Permissions.partyChat(sender)) {
sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle"));
}
sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite"));
sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept"));
if (Permissions.partySubcommand(sender, PartySubcommandType.TELEPORT)) {
sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport"));
}
}
}
private void displayOtherCommands(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Other"));
sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats"));
sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards"));
if (Permissions.skillreset(sender)) {
sender.sendMessage("/skillreset <skill|all> " + LocaleLoader.getString("Commands.Reset"));
}
return false;
if (Permissions.mcability(sender)) {
sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility"));
}
if (Permissions.adminChat(sender)) {
sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle"));
}
if (Permissions.inspect(sender)) {
sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect"));
}
if (Permissions.mmoedit(sender)) {
sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit"));
}
if (Permissions.mcgod(sender)) {
sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod"));
}
sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo"));
}
}

View File

@@ -0,0 +1,34 @@
package com.gmail.nossr50.commands.player;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Users;
public class McnotifyCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
PlayerProfile profile = Users.getPlayer((Player) sender).getProfile();
if (profile.useChatNotifications()) {
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.Off"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Notifications.On"));
}
profile.toggleChatNotifications();
return true;
default:
return false;
}
}
}

View File

@@ -24,7 +24,7 @@ public class McrankCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrank")) {
if (!Permissions.mcrank(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -44,7 +44,7 @@ public class McrankCommand implements CommandExecutor {
return true;
case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcrank.others")) {
if (!Permissions.mcrankOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
@@ -59,7 +59,7 @@ public class McrankCommand implements CommandExecutor {
return true;
}
if (sender instanceof Player && !!Permissions.hasPermission(sender, "mcmmo.commands.mcrank.others.offline")) {
if (sender instanceof Player && !Permissions.mcrankOffline(sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
return true;
}
@@ -67,7 +67,7 @@ public class McrankCommand implements CommandExecutor {
else {
Player target = mcMMOPlayer.getPlayer();
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.hasPermission(sender, "mcmmo.commands.mcrank.others.far")) {
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.mcrankFar(sender)) {
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
return true;
}
@@ -100,10 +100,10 @@ public class McrankCommand implements CommandExecutor {
}
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), String.valueOf(rankInts[0])));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), rankInts[0]));
}
}
@@ -111,10 +111,10 @@ public class McrankCommand implements CommandExecutor {
int[] rankInts = Leaderboard.getPlayerRank(playerName);
if (rankInts[1] == 0) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overalll", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", LocaleLoader.getString("Commands.mcrank.Unranked"))); // Don't bother showing ranking for players without skills
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", String.valueOf(rankInts[0])));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Overall", rankInts[0]));
}
}

View File

@@ -35,10 +35,10 @@ public class McstatsCommand implements CommandExecutor {
int powerLevelCap = Config.getInstance().getPowerLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", String.valueOf(mcMMOPlayer.getPowerLevel()), String.valueOf(powerLevelCap)));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", mcMMOPlayer.getPowerLevel(), powerLevelCap));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", String.valueOf(mcMMOPlayer.getPowerLevel())));
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
}
return true;

View File

@@ -1,20 +1,20 @@
package com.gmail.nossr50.commands.player;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.database.Leaderboard;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.McTopAsync;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public class MctopCommand implements CommandExecutor {
@Override
@@ -23,18 +23,15 @@ public class MctopCommand implements CommandExecutor {
switch (args.length) {
case 0:
display(1, "ALL", sender, useMySQL);
display(1, "ALL", sender, useMySQL, command);
return true;
case 1:
if (Misc.isInt(args[0])) {
display(Integer.valueOf(args[0]), "ALL", sender, useMySQL);
if (StringUtils.isInt(args[0])) {
display(Integer.parseInt(args[0]), "ALL", sender, useMySQL, command);
}
else if (SkillTools.isSkill(args[0])) {
display(1, args[0], sender, useMySQL);
}
else if (SkillTools.isLocalizedSkill(args[0])) {
display(1, SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL);
display(1, SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
@@ -43,15 +40,12 @@ public class MctopCommand implements CommandExecutor {
return true;
case 2:
if (!Misc.isInt(args[1])) {
if (!StringUtils.isInt(args[1])) {
return false;
}
if (SkillTools.isSkill(args[0])) {
display(Integer.valueOf(args[1]), args[0], sender, useMySQL);
}
else if (SkillTools.isLocalizedSkill(args[0])) {
display(Integer.valueOf(args[1]), SkillTools.translateLocalizedSkill(args[0]), sender, useMySQL);
display(Integer.parseInt(args[1]), SkillType.getSkill(args[0]).toString(), sender, useMySQL, command);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Invalid"));
@@ -64,22 +58,23 @@ public class MctopCommand implements CommandExecutor {
}
}
private void display(int page, String skill, CommandSender sender, boolean sql) {
private void display(int page, String skill, CommandSender sender, boolean sql, Command command) {
if (sql) {
if (skill.equalsIgnoreCase("all")) {
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender);
sqlDisplay(page, "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing", sender, command);
}
else {
sqlDisplay(page, skill, sender);
sqlDisplay(page, skill, sender, command);
}
}
else {
flatfileDisplay(page, skill, sender);
flatfileDisplay(page, skill, sender, command);
}
}
private void flatfileDisplay(int page, String skill, CommandSender sender) {
if (!skill.equalsIgnoreCase("all") && CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mctop." + skill.toLowerCase())) {
private void flatfileDisplay(int page, String skill, CommandSender sender, Command command) {
if (!skill.equalsIgnoreCase("all") && !Permissions.mctop(sender, SkillType.getSkill(skill))) {
sender.sendMessage(command.getPermissionMessage());
return;
}
@@ -91,7 +86,7 @@ public class MctopCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(skill)));
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(skill)));
}
int n = (page * 10) - 9; // Position
@@ -114,33 +109,7 @@ public class MctopCommand implements CommandExecutor {
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
private void sqlDisplay(int page, String query, CommandSender sender) {
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mctop." + query.toLowerCase())) {
return;
}
}
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
HashMap<Integer, ArrayList<String>> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT "+((page * 10) - 10)+",10");
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", Misc.getCapitalized(query)));
}
int place = (page * 10) - 9;
for (int i = 1; i <= 10; i++) {
if (userslist.get(i) == null) {
break;
}
// Format: 1. Playername - skill value
sender.sendMessage(String.valueOf(place) + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
place++;
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
private void sqlDisplay(int page, String query, CommandSender sender, Command command) {
Bukkit.getScheduler().runTaskAsynchronously(mcMMO.p, new McTopAsync(page, query, sender, command));
}
}

View File

@@ -107,7 +107,7 @@ public class AdvancedConfig extends ConfigLoader {
public int getHerbalismDoubleDropsMaxLevel() { return config.getInt("Skills.Herbalism.DoubleDrops_MaxBonusLevel", 1000); }
public double getHylianLuckChanceMax() { return config.getDouble("Skills.Herbalism.HylianLuck_ChanceMax", 10.0D); }
public int getHylianLucksMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
public int getHylianLuckMaxLevel() { return config.getInt("Skills.Herbalism.HylianLuck_MaxBonusLevel", 1000); }
/* MINING */
public double getMiningDoubleDropChance() { return config.getDouble("Skills.Mining.DoubleDrops_ChanceMax", 100.0D); }

View File

@@ -2,9 +2,13 @@ package com.gmail.nossr50.config;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.StringUtils;
public class Config extends ConfigLoader {
private static Config instance;
@@ -35,7 +39,11 @@ public class Config extends ConfigLoader {
public boolean getDonateMessageEnabled() { return config.getBoolean("Commands.mcmmo.Donate_Message", true); }
public int getSaveInterval() { return config.getInt("General.Save_Interval", 10); }
public boolean getStatsTrackingEnabled() { return config.getBoolean("General.Stats_Tracking", true); }
public boolean getUpdateCheckEnabled() { return config.getBoolean("General.Update_Check", true); }
public boolean getPreferBeta() { return config.getBoolean("General.Prefer_Beta", false); }
public boolean getEventCallbackEnabled() { return config.getBoolean("General.Event_Callback", true); }
public boolean getBackupsEnabled() { return config.getBoolean("General.Generate_Backups", true); }
public boolean getVerboseLoggingEnabled() { return config.getBoolean("General.Verbose_Logging", false); }
public boolean getPartyDisplayNames() { return config.getBoolean("Commands.p.Use_Display_Names", true); }
public boolean getAdminDisplayNames() { return config.getBoolean("Commands.a.Use_Display_Names", true); }
@@ -61,18 +69,29 @@ public class Config extends ConfigLoader {
private static String getStringIncludingInts(ConfigurationSection cfg, String key) {
String str = cfg.getString(key);
if (str == null)
if (str == null) {
str = String.valueOf(cfg.getInt(key));
if (str == null)
}
if (str == "0") {
str = "No value set for '" + key + "'";
}
return str;
}
/* Hardcore Mode */
public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); }
public void setHardcoreEnabled(boolean enabled) { config.set("Hardcore.Enabled", enabled); }
public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75.0); }
public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss_Penalty_Percentage", value); }
public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5.0); }
public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism_Stat_Leech_Percentage", value); }
public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); }
public void setHardcoreVampirismEnabled(boolean enabled) { config.set("Hardcore.Vampirism", enabled); }
/* SMP Mods */
public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); }
@@ -80,6 +99,11 @@ public class Config extends ConfigLoader {
public boolean getBlockModsEnabled() { return config.getBoolean("Mods.Block_Mods_Enabled", false); }
public boolean getEntityModsEnabled() { return config.getBoolean("Mods.Entity_Mods_Enabled", false); }
/* Items */
public int getChimaeraCost() { return config.getInt("Items.Chimaera_Wing.Feather_Cost", 10); }
public int getChimaeraItemId() { return config.getInt("Items.Chimaera_Wing.Item_ID", 288); }
public boolean getChimaeraEnabled() { return config.getBoolean("Items.Chimaera_Wing.Enabled", true); }
/* PARTY SETTINGS */
public int getAutoPartyKickInterval() { return config.getInt("Party.AutoKick_Interval", 12); }
public int getAutoPartyKickTime() { return config.getInt("Party.Old_Party_Member_Cutoff", 7); }
@@ -105,30 +129,13 @@ public class Config extends ConfigLoader {
public boolean getAbilitiesEnabled() { return config.getBoolean("Abilities.Enabled", true); }
public boolean getAbilitiesOnlyActivateWhenSneaking() { return config.getBoolean("Abilities.Activation.Only_Activate_When_Sneaking", false); }
public int getCooldown(AbilityType ability) { return config.getInt("Abilities.Cooldowns." + ability.toString()); }
public int getMaxTicks(AbilityType ability) { return config.getInt("Abilities.Max_Seconds." + ability.toString()); }
/* Durability Settings */
public boolean getAbilitiesDamageTools() { return config.getBoolean("Abilities.Tools.Durability_Loss_Enabled", true); }
public int getAbilityToolDamage() { return config.getInt("Abilities.Tools.Durability_Loss", 2); }
/* Cooldowns */
public int getAbilityCooldownGreenTerra() { return config.getInt("Abilities.Cooldowns.Green_Terra", 240); }
public int getAbilityCooldownSuperBreaker() { return config.getInt("Abilities.Cooldowns.Super_Breaker", 240); }
public int getAbilityCooldownGigaDrillBreaker() { return config.getInt("Abilities.Cooldowns.Giga_Drill_Breaker", 240); }
public int getAbilityCooldownTreeFeller() { return config.getInt("Abilities.Cooldowns.Tree_Feller", 240); }
public int getAbilityCooldownBerserk() { return config.getInt("Abilities.Cooldowns.Berserk", 240); }
public int getAbilityCooldownSerratedStrikes() { return config.getInt("Abilities.Cooldowns.Serrated_Strikes", 240); }
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); }
@@ -136,275 +143,13 @@ public class Config extends ConfigLoader {
* SKILL SETTINGS
*/
/* Tool Requirements */
public boolean getMiningRequiresTool() { return config.getBoolean("Skills.Mining.Requires_Pickaxe", true); }
public boolean getExcavationRequiresTool() { return config.getBoolean("Skills.Excavation.Requires_Shovel", true); }
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public boolean getDoubleDropsEnabled(SkillType skill, Material material) { return config.getBoolean("Double_Drops." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
/* Excavation */
public int getExcavationClayXP() { return config.getInt("Experience.Excavation.Clay", 40); }
public int getExcavationDirtXP() { return config.getInt("Experience.Excavation.Dirt", 40); }
public int getExcavationGrassXP() { return config.getInt("Experience.Excavation.Grass", 40); }
public int getExcavationGravelXP() { return config.getInt("Experience.Excavation.Gravel", 40); }
public int getExcavationMycelXP() { return config.getInt("Experience.Excavation.Mycel", 40); }
public int getExcavationSandXP() { return config.getInt("Experience.Excavation.Sand", 40); }
public int getExcavationSoulSandXP() { return config.getInt("Experience.Excavation.SoulSand", 40); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Herbalism */
public int getHerbalismXPSugarCane() { return config.getInt("Experience.Herbalism.Sugar_Cane", 30); }
public int getHerbalismXPWheat() { return config.getInt("Experience.Herbalism.Wheat", 50); }
public int getHerbalismXPCactus() { return config.getInt("Experience.Herbalism.Cactus", 30); }
public int getHerbalismXPPumpkin() { return config.getInt("Experience.Herbalism.Pumpkin", 20); }
public int getHerbalismXPFlowers() { return config.getInt("Experience.Herbalism.Flowers", 100); }
public int getHerbalismXPMushrooms() { return config.getInt("Experience.Herbalism.Mushrooms", 150); }
public int getHerbalismXPMelon() { return config.getInt("Experience.Herbalism.Melon", 20); }
public int getHerbalismXPNetherWart() { return config.getInt("Experience.Herbalism.Nether_Wart", 50); }
public int getHerbalismXPLilyPads() { return config.getInt("Experience.Herbalism.Lily_Pads", 100); }
public int getHerbalismXPVines() { return config.getInt("Experience.Herbalism.Vines", 10); }
public int getHerbalismXPCocoa() { return config.getInt("Experience.Herbalism.Cocoa", 30); }
public int getHerbalismXPCarrot() { return config.getInt("Experience.Herbalism.Carrot", 50); }
public int getHerbalismXPPotato() { return config.getInt("Experience.Herbalism.Potato", 50); }
public boolean getHerbalismGreenThumbCobbleToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Cobble_To_Mossy", true); }
public boolean getHerbalismGreenThumbCobbleWallToMossyWall() { return config.getBoolean("Skills.Herbalism.Green_Thumb.CobbleWall_To_MossyWall", true); }
public boolean getHerbalismGreenThumbSmoothbrickToMossy() { return config.getBoolean("Skills.Herbalism.Green_Thumb.SmoothBrick_To_MossyBrick", true); }
public boolean getHerbalismGreenThumbDirtToGrass() { return config.getBoolean("Skills.Herbalism.Green_Thumb.Dirt_To_Grass", true); }
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 getCocoaDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Cocoa", true); }
public boolean getCarrotDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Carrot", true); }
public boolean getPotatoDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Herbalism.Potato", true); }
public boolean herbalismDoubleDropsDisabled() {
return doubleDropsDisabled("Herbalism");
}
/* Mining */
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); }
public int getMiningXPLapisOre() { return config.getInt("Experience.Mining.Lapis", 400); }
public int getMiningXPObsidian() { return config.getInt("Experience.Mining.Obsidian", 150); }
public int getMiningXPNetherrack() { return config.getInt("Experience.Mining.Netherrack", 30); }
public int getMiningXPGlowstone() { return config.getInt("Experience.Mining.Glowstone", 30); }
public int getMiningXPCoalOre() { return config.getInt("Experience.Mining.Coal", 100); }
public int getMiningXPStone() { return config.getInt("Experience.Mining.Stone", 30); }
public int getMiningXPSandstone() { return config.getInt("Experience.Mining.Sandstone", 30); }
public int getMiningXPEndStone() { return config.getInt("Experience.Mining.End_Stone", 150); }
public int getMiningXPMossyStone() { return config.getInt("Experience.Mining.Moss_Stone", 30); }
public int getMiningXPEmeraldOre() { return config.getInt("Experience.Mining.Emerald", 1000); }
public boolean getCoalDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Coal", true); }
public boolean getDiamondDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Diamond", true); }
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 getEmeraldDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Mining.Emerald", true); }
public boolean miningDoubleDropsDisabled() {
return doubleDropsDisabled("Mining");
}
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 boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
/* Smelting */
public int getSmeltingXPCoal() { return config.getInt("Experience.Smelting.Coal", 10); }
public int getSmeltingXPRedstone() { return config.getInt("Experience.Smelting.Redstone", 15); }
public int getSmeltingXPIron() { return config.getInt("Experience.Smelting.Iron", 25); }
public int getSmeltingXPGold() { return config.getInt("Experience.Smelting.Gold", 35); }
public int getSmeltingXPDiamond() { return config.getInt("Experience.Smelting.Diamond", 75); }
public int getSmeltingXPLapis() { return config.getInt("Experience.Smelting.Lapis", 40); }
public int getSmeltingXPEmerald() { return config.getInt("Experience.Smelting.Emerald", 100); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
/* Woodcutting */
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public 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() {
return doubleDropsDisabled("Woodcutting");
}
/* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Dogde Lightning */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
/* Level Caps */
public int getLevelCapAcrobatics() {
return getLevelCap("Skills.Acrobatics.Level_Cap");
}
public int getLevelCapArchery() {
return getLevelCap("Skills.Archery.Level_Cap");
}
public int getLevelCapAxes() {
return getLevelCap("Skills.Axes.Level_Cap");
}
public int getLevelCapExcavation() {
return getLevelCap("Skills.Excavation.Level_Cap");
}
public int getLevelCapFishing() {
return getLevelCap("Skills.Fishing.Level_Cap");
}
public int getLevelCapHerbalism() {
return getLevelCap("Skills.Herbalism.Level_Cap");
}
public int getLevelCapMining() {
return getLevelCap("Skills.Mining.Level_Cap");
}
public int getLevelCapRepair() {
return getLevelCap("Skills.Repair.Level_Cap");
}
public int getLevelCapSmelting() {
return getLevelCap("Skills.Smelting.Level_Cap");
}
public int getLevelCapSwords() {
return getLevelCap("Skills.Swords.Level_Cap");
}
public int getLevelCapTaming() {
return getLevelCap("Skills.Taming.Level_Cap");
}
public int getLevelCapUnarmed() {
return getLevelCap("Skills.Unarmed.Level_Cap");
}
public int getLevelCapWoodcutting() {
return getLevelCap("Skills.Woodcutting.Level_Cap");
}
public int getPowerLevelCap() {
return getLevelCap("General.Power_Level_Cap");
}
/* PVP & PVE Settings */
public boolean getAcrobaticsPVP() { return config.getBoolean("Skills.Acrobatics.Enabled_For_PVP", true); }
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
*/
/* General Settings */
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double 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); }
public double getSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Spider", 3.0); }
public double getGhastXP() { return config.getDouble("Experience.Combat.Multiplier.Ghast", 3.0); }
public double getSlimeXP() { return config.getDouble("Experience.Combat.Multiplier.Slime", 2.0); }
public double getZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Zombie", 2.0); }
public double getPigZombieXP() { return config.getDouble("Experience.Combat.Multiplier.Pig_Zombie", 3.0); }
public double getEndermanXP() { return config.getDouble("Experience.Combat.Multiplier.Enderman", 1.0); }
public double getCaveSpiderXP() { return config.getDouble("Experience.Combat.Multiplier.Cave_Spider", 3.0); }
public double getSilverfishXP() { return config.getDouble("Experience.Combat.Multiplier.Silverfish", 3.0); }
public double getBlazeXP() { return config.getDouble("Experience.Combat.Multiplier.Blaze", 3.0); }
public double getMagmaCubeXP() { return config.getDouble("Experience.Combat.Multiplier.Magma_Cube", 2.0); }
public double getEnderDragonXP() { return config.getDouble("Experience.Combat.Multiplier.Ender_Dragon", 8.0); }
public double getIronGolemXP() { return config.getDouble("Experience.Combat.Multiplier.Iron_Golem", 2.0); }
public double getGiantXP() { return config.getDouble("Experience.Combat.Multiplier.Giant", 4.0); }
public double getWitherXP() { return config.getDouble("Experience.Combat.Multiplier.Wither", 7.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
public double getWitchXP() { return config.getDouble("Experience.Combat.Multiplier.Witch", 4.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
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); }
public double getFormulaMultiplierWoodcutting() { return config.getDouble("Experience.Formula.Multiplier.Woodcutting", 1.0); }
public double getFormulaMultiplierUnarmed() { return config.getDouble("Experience.Formula.Multiplier.Unarmed", 1.0); }
public double getFormulaMultiplierHerbalism() { return config.getDouble("Experience.Formula.Multiplier.Herbalism", 1.0); }
public double getFormulaMultiplierExcavation() { return config.getDouble("Experience.Formula.Multiplier.Excavation", 1.0); }
public double getFormulaMultiplierArchery() { return config.getDouble("Experience.Formula.Multiplier.Archery", 1.0); }
public double getFormulaMultiplierSwords() { return config.getDouble("Experience.Formula.Multiplier.Swords", 1.0); }
public double getFormulaMultiplierAxes() { return config.getDouble("Experience.Formula.Multiplier.Axes", 1.0); }
public double getFormulaMultiplierAcrobatics() { return config.getDouble("Experience.Formula.Multiplier.Acrobatics", 1.0); }
public double getFormulaMultiplierFishing() { return config.getDouble("Experience.Formula.Multiplier.Fishing", 1.0); }
private boolean doubleDropsDisabled(String skillName) {
public boolean getDoubleDropsDisabled(SkillType skill) {
String skillName = StringUtils.getCapitalized(skill.toString());
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
if (section == null) {
mcMMO.p.getLogger().warning("The configuration files are outdated!"); //TODO Locale and more descriptive message!
return false;
}
Set<String> keys = section.getKeys(false);
boolean disabled = true;
for (String key : keys) {
@@ -417,8 +162,88 @@ public class Config extends ConfigLoader {
return disabled;
}
private int getLevelCap(String configString) {
int cap = config.getInt(configString, 0);
return ((cap <= 0) ? Integer.MAX_VALUE : cap);
/* Acrobatics */
public boolean getDodgeLightningDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_Dodge_Lightning", false); }
/* Fishing */
public int getFishingBaseXP() { return config.getInt("Experience.Fishing.Base", 800); }
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
/* Mining */
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 boolean getSalvageEnabled() { return config.getBoolean("Skills.Repair.Salvage_enabled", true); }
public int getSalvageAnvilId() { return config.getInt("Skills.Repair.Salvage_Anvil_ID", 41); }
public int getSalvageUnlockLevel() { return config.getInt("Skills.Repair.Salvage_UnlockLevel", 600); }
public boolean getSalvageTools() { return config.getBoolean("Skills.Repair.Salvage_tools", true); }
public boolean getSalvageArmor() { return config.getBoolean("Skills.Repair.Salvage_armor", true); }
/* Unarmed */
public boolean getUnarmedBlockCrackerSmoothbrickToCracked() { return config.getBoolean("Skills.Unarmed.Block_Cracker.SmoothBrick_To_CrackedBrick", true); }
/* Taming */
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
public int getTamingCOTWWolfCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Bones_Required", 10); }
public int getTamingCOTWOcelotCost() { return config.getInt("Skills.Taming.Call_Of_The_Wild.Fish_Required", 10); }
/* Woodcutting */
public boolean getWoodcuttingRequiresTool() { return config.getBoolean("Skills.Woodcutting.Requires_Axe", true); }
public int getWoodcuttingXPOak() { return config.getInt("Experience.Woodcutting.Oak", 70); }
public int getWoodcuttingXPBirch() { return config.getInt("Experience.Woodcutting.Birch", 90); }
public int getWoodcuttingXPSpruce() { return config.getInt("Experience.Woodcutting.Spruce", 80); }
public int getWoodcuttingXPJungle() { return config.getInt("Experience.Woodcutting.Jungle", 100); }
public int getWoodcuttingXPHugeBrownMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Brown", 70); }
public int getWoodcuttingXPHugeRedMushroom() { return config.getInt("Experience.Woodcutting.Huge_Mushroom_Red", 70); }
public boolean getOakDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Oak", true); }
public boolean getBirchDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Birch", true); }
public boolean getSpruceDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Spruce", true); }
public boolean getJungleDoubleDropsEnabled() { return config.getBoolean("Double_Drops.Woodcutting.Jungle", true); }
/* AFK Leveling */
public boolean getAcrobaticsAFKDisabled() { return config.getBoolean("Skills.Acrobatics.Prevent_AFK_Leveling", true); }
public boolean getHerbalismAFKDisabled() { return config.getBoolean("Skills.Herbalism.Prevent_AFK_Leveling", true); }
/* Level Caps */
public int getPowerLevelCap() {
int cap = config.getInt("General.Power_Level_Cap", 0);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
public int getLevelCap(SkillType skill) {
int cap = config.getInt("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Level_Cap");
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
/* PVP & PVE Settings */
public boolean getPVPEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVP", true); }
public boolean getPVEEnabled(SkillType skill) { return config.getBoolean("Skills." + StringUtils.getCapitalized(skill.toString()) + ".Enabled_For_PVE", true); }
/*
* XP SETTINGS
*/
/* General Settings */
public boolean getExperienceGainsMobspawnersEnabled() { return config.getBoolean("Experience.Gains.Mobspawners.Enabled", false); }
public boolean getExperienceGainsPlayerVersusPlayerEnabled() { return config.getBoolean("Experience.PVP.Rewards", true); }
public double getExperienceGainsGlobalMultiplier() { return config.getDouble("Experience.Gains.Multiplier.Global", 1.0); }
public void setExperienceGainsGlobalMultiplier(double value) { config.set("Experience.Gains.Multiplier.Global", value); }
/* Combat XP Multipliers */
public double getPlayerVersusPlayerXP() { return config.getDouble("Experience.Gains.Multiplier.PVP", 1.0); }
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
/* XP Formula Multiplier */
public int getFormulaMultiplierCurve() { return config.getInt("Experience.Formula.Curve_Modifier", 20); }
public double getForumulaMultiplier(SkillType skill) { return config.getDouble("Experience.Formula.Multiplier." + StringUtils.getCapitalized(skill.toString())); }
}

View File

@@ -1,14 +1,22 @@
package com.gmail.nossr50.config;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.metrics.MetricsManager;
public abstract class ConfigLoader {
protected static final mcMMO plugin = mcMMO.p;
@@ -38,6 +46,98 @@ public abstract class ConfigLoader {
}
config = YamlConfiguration.loadConfiguration(configFile);
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
Set<String> configKeys = config.getKeys(true);
Set<String> internalConfigKeys = internalConfig.getKeys(true);
boolean needSave = false;
Set<String> oldKeys = new HashSet<String>(configKeys);
oldKeys.removeAll(internalConfigKeys);
Set<String> newKeys = new HashSet<String>(internalConfigKeys);
newKeys.removeAll(configKeys);
// Don't need a re-save if we have old keys sticking around?
// Would be less saving, but less... correct?
if (!newKeys.isEmpty() || !oldKeys.isEmpty()) {
needSave = true;
}
for (String key : oldKeys) {
plugin.debug("Removing unused key: " + key);
config.set(key, null);
}
for (String key : newKeys) {
plugin.debug("Adding new key: " + key + " = " + internalConfig.get(key));
config.set(key, internalConfig.get(key));
}
if (needSave) {
// Get Bukkit's version of an acceptable config with new keys, and no old keys
String output = config.saveToString();
// Convert to the superior 4 space indentation
output = output.replace(" ", " ");
// Rip out Bukkit's attempt to save comments at the top of the file
while (output.indexOf('#') != -1) {
output = output.substring(output.indexOf('\n', output.indexOf('#'))+1);
}
// Read the internal config to get comments, then put them in the new one
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
HashMap<String, String> comments = new HashMap<String, String>();
String temp = "";
String line;
while ((line = reader.readLine()) != null) {
if (line.contains("#")) {
temp += line + "\n";
}
else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if(!temp.isEmpty()) {
comments.put(line, temp);
temp = "";
}
}
}
// Dump to the new one
for (String key : comments.keySet()) {
if (output.indexOf(key) != -1) {
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
}
}
}
catch (Exception e) {
e.printStackTrace();
}
// Save it
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(new File(plugin.getDataFolder(), fileName)));
writer.write(output);
writer.flush();
writer.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
else {
for (String key : configKeys) {
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
MetricsManager.customConfig();
break;
}
}
}
}
protected abstract void loadKeys();

View File

@@ -10,6 +10,7 @@ public class HiddenConfig {
private static YamlConfiguration config;
private static boolean chunkletsEnabled;
private static int conversionRate;
private static boolean useEnchantmentBuffs;
public HiddenConfig(String fileName) {
HiddenConfig.fileName = fileName;
@@ -29,6 +30,7 @@ public class HiddenConfig {
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
}
}
@@ -39,4 +41,8 @@ public class HiddenConfig {
public int getConversionRate() {
return conversionRate;
}
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}
}

View File

@@ -173,13 +173,14 @@ public final class Database {
write("ALTER TABLE `" + tablePrefix + "experience` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
write("ALTER TABLE `" + tablePrefix + "cooldowns` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
write("ALTER TABLE `" + tablePrefix + "skills` ADD FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE;");
break;
case FISHING:
sql = "SELECT * FROM `" + tablePrefix + "experience` ORDER BY `" + tablePrefix + "experience`.`fishing` ASC LIMIT 0 , 30";
break;
case INDEX:
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13) {
if (read("SHOW INDEX FROM " + tablePrefix + "skills").size() != 13 && checkConnected()) {
mcMMO.p.getLogger().info("Indexing tables, this may take a while on larger databases");
write("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_taming` (`taming`) USING BTREE, "
+ "ADD INDEX `idx_mining` (`mining`) USING BTREE, "
@@ -579,9 +580,9 @@ public final class Database {
}
private static void printErrors(SQLException ex) {
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
mcMMO.p.getLogger().severe("SQLException: " + ex.getMessage());
mcMMO.p.getLogger().severe("SQLState: " + ex.getSQLState());
mcMMO.p.getLogger().severe("VendorError: " + ex.getErrorCode());
}
public static void profileCleanup(String playerName) {

View File

@@ -15,7 +15,7 @@ import org.bukkit.Bukkit;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public final class Leaderboard {
private static HashMap<SkillType, List<PlayerStat>> playerStatHash = new HashMap<SkillType, List<PlayerStat>>();
@@ -71,64 +71,64 @@ public final class Leaderboard {
players.add(p);
if (character.length > 1 && Misc.isInt(character[1])) {
mining.add(new PlayerStat(p, Integer.valueOf(character[1])));
powerLevel += Integer.valueOf(character[1]);
if (character.length > 1 && StringUtils.isInt(character[1])) {
mining.add(new PlayerStat(p, Integer.parseInt(character[1])));
powerLevel += Integer.parseInt(character[1]);
}
if (character.length > 5 && Misc.isInt(character[5])) {
woodcutting.add(new PlayerStat(p, Integer.valueOf(character[5])));
powerLevel += Integer.valueOf(character[5]);
if (character.length > 5 && StringUtils.isInt(character[5])) {
woodcutting.add(new PlayerStat(p, Integer.parseInt(character[5])));
powerLevel += Integer.parseInt(character[5]);
}
if (character.length > 7 && Misc.isInt(character[7])) {
repair.add(new PlayerStat(p, Integer.valueOf(character[7])));
powerLevel += Integer.valueOf(character[7]);
if (character.length > 7 && StringUtils.isInt(character[7])) {
repair.add(new PlayerStat(p, Integer.parseInt(character[7])));
powerLevel += Integer.parseInt(character[7]);
}
if (character.length > 8 && Misc.isInt(character[8])) {
unarmed.add(new PlayerStat(p, Integer.valueOf(character[8])));
powerLevel += Integer.valueOf(character[8]);
if (character.length > 8 && StringUtils.isInt(character[8])) {
unarmed.add(new PlayerStat(p, Integer.parseInt(character[8])));
powerLevel += Integer.parseInt(character[8]);
}
if (character.length > 9 && Misc.isInt(character[9])) {
herbalism.add(new PlayerStat(p, Integer.valueOf(character[9])));
powerLevel += Integer.valueOf(character[9]);
if (character.length > 9 && StringUtils.isInt(character[9])) {
herbalism.add(new PlayerStat(p, Integer.parseInt(character[9])));
powerLevel += Integer.parseInt(character[9]);
}
if (character.length > 10 && Misc.isInt(character[10])) {
excavation.add(new PlayerStat(p, Integer.valueOf(character[10])));
powerLevel += Integer.valueOf(character[10]);
if (character.length > 10 && StringUtils.isInt(character[10])) {
excavation.add(new PlayerStat(p, Integer.parseInt(character[10])));
powerLevel += Integer.parseInt(character[10]);
}
if (character.length > 11 && Misc.isInt(character[11])) {
archery.add(new PlayerStat(p, Integer.valueOf(character[11])));
powerLevel += Integer.valueOf(character[11]);
if (character.length > 11 && StringUtils.isInt(character[11])) {
archery.add(new PlayerStat(p, Integer.parseInt(character[11])));
powerLevel += Integer.parseInt(character[11]);
}
if (character.length > 12 && Misc.isInt(character[12])) {
swords.add(new PlayerStat(p, Integer.valueOf(character[12])));
powerLevel += Integer.valueOf(character[12]);
if (character.length > 12 && StringUtils.isInt(character[12])) {
swords.add(new PlayerStat(p, Integer.parseInt(character[12])));
powerLevel += Integer.parseInt(character[12]);
}
if (character.length > 13 && Misc.isInt(character[13])) {
axes.add(new PlayerStat(p, Integer.valueOf(character[13])));
powerLevel += Integer.valueOf(character[13]);
if (character.length > 13 && StringUtils.isInt(character[13])) {
axes.add(new PlayerStat(p, Integer.parseInt(character[13])));
powerLevel += Integer.parseInt(character[13]);
}
if (character.length > 14 && Misc.isInt(character[14])) {
acrobatics.add(new PlayerStat(p, Integer.valueOf(character[14])));
powerLevel += Integer.valueOf(character[14]);
if (character.length > 14 && StringUtils.isInt(character[14])) {
acrobatics.add(new PlayerStat(p, Integer.parseInt(character[14])));
powerLevel += Integer.parseInt(character[14]);
}
if (character.length > 24 && Misc.isInt(character[24])) {
taming.add(new PlayerStat(p, Integer.valueOf(character[24])));
powerLevel += Integer.valueOf(character[24]);
if (character.length > 24 && StringUtils.isInt(character[24])) {
taming.add(new PlayerStat(p, Integer.parseInt(character[24])));
powerLevel += Integer.parseInt(character[24]);
}
if (character.length > 34 && Misc.isInt(character[34])) {
fishing.add(new PlayerStat(p, Integer.valueOf(character[34])));
powerLevel += Integer.valueOf(character[34]);
if (character.length > 34 && StringUtils.isInt(character[34])) {
fishing.add(new PlayerStat(p, Integer.parseInt(character[34])));
powerLevel += Integer.parseInt(character[34]);
}
powerLevels.add(new PlayerStat(p, powerLevel));
@@ -279,7 +279,7 @@ public final class Leaderboard {
writer.append(line).append("\r\n");
}
else {
System.out.println("User found, removing...");
mcMMO.p.getLogger().info("User found, removing...");
worked = true;
continue; //Skip the player
}
@@ -355,11 +355,11 @@ public final class Leaderboard {
String[] splitLine = line.split(":");
if (splitLine.length > 37) {
if (currentTime - (Misc.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
if (currentTime - (StringUtils.getLong(line.split(":")[37]) * 1000) <= purgeTime) {
writer.append(line).append("\r\n");
}
else {
System.out.println("User found, removing...");
mcMMO.p.getLogger().info("User found, removing...");
removedPlayers++;
continue; //Skip the player
}

View File

@@ -42,4 +42,4 @@ public class MmoupdateCommand implements CommandExecutor {
mcMMO.p.getServer().getScheduler().runTaskLaterAsynchronously(mcMMO.p, new SQLConversionTask(), 1);
}
}
}

View File

@@ -7,6 +7,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public class SQLConversionTask implements Runnable {
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
@@ -20,7 +21,7 @@ public class SQLConversionTask implements Runnable {
BufferedReader in = new BufferedReader(file);
String line = "";
String playerName = null;
String party = null;
//String party = null;
String mining = null;
String woodcutting = null;
String repair = null;
@@ -62,10 +63,13 @@ public class SQLConversionTask implements Runnable {
if (character.length > 1) {
mining = character[1];
}
/*
* Looks like we still have party as the 4th string in the array but we don't use it anymore
if (character.length > 3) {
party = character[3];
}
*/
if (character.length > 4) {
miningXP = character[4];
@@ -175,34 +179,34 @@ public class SQLConversionTask implements Runnable {
Database.write("UPDATE "
+ tablePrefix
+ "skills SET "
+ " taming = taming+" + Misc.getInt(taming)
+ ", mining = mining+" + Misc.getInt(mining)
+ ", repair = repair+" + Misc.getInt(repair)
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
+ ", excavation = excavation+" + Misc.getInt(excavation)
+ ", archery = archery+" + Misc.getInt(archery)
+ ", swords = swords+" + Misc.getInt(swords)
+ ", axes = axes+" + Misc.getInt(axes)
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
+ ", fishing = fishing+" + Misc.getInt(fishing)
+ " taming = taming+" + StringUtils.getInt(taming)
+ ", mining = mining+" + StringUtils.getInt(mining)
+ ", repair = repair+" + StringUtils.getInt(repair)
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
+ ", archery = archery+" + StringUtils.getInt(archery)
+ ", swords = swords+" + StringUtils.getInt(swords)
+ ", axes = axes+" + StringUtils.getInt(axes)
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
+ " WHERE user_id = " + id);
Database.write("UPDATE "
+ tablePrefix
+ "experience SET "
+ " taming = " + Misc.getInt(tamingXP)
+ ", mining = " + Misc.getInt(miningXP)
+ ", repair = " + Misc.getInt(repairXP)
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
+ ", unarmed = " + Misc.getInt(unarmedXP)
+ ", herbalism = " + Misc.getInt(herbalismXP)
+ ", excavation = " + Misc.getInt(excavationXP)
+ ", archery = " + Misc.getInt(archeryXP)
+ ", swords = " + Misc.getInt(swordsXP)
+ ", axes = " + Misc.getInt(axesXP)
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
+ ", fishing = " + Misc.getInt(fishingXP)
+ " taming = " + StringUtils.getInt(tamingXP)
+ ", mining = " + StringUtils.getInt(miningXP)
+ ", repair = " + StringUtils.getInt(repairXP)
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
+ ", excavation = " + StringUtils.getInt(excavationXP)
+ ", archery = " + StringUtils.getInt(archeryXP)
+ ", swords = " + StringUtils.getInt(swordsXP)
+ ", axes = " + StringUtils.getInt(axesXP)
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
+ ", fishing = " + StringUtils.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
else {
@@ -230,46 +234,48 @@ public class SQLConversionTask implements Runnable {
+ tablePrefix
+ "users SET lastlogin = " + 0
+ " WHERE id = " + id);
/*
Database.write("UPDATE "
+ tablePrefix
+ "users SET party = '" + party
+ "' WHERE id = " + id);
*/
Database.write("UPDATE "
+ tablePrefix
+ "skills SET "
+ " taming = taming+" + Misc.getInt(taming)
+ ", mining = mining+" + Misc.getInt(mining)
+ ", repair = repair+" + Misc.getInt(repair)
+ ", woodcutting = woodcutting+" + Misc.getInt(woodcutting)
+ ", unarmed = unarmed+" + Misc.getInt(unarmed)
+ ", herbalism = herbalism+" + Misc.getInt(herbalism)
+ ", excavation = excavation+" + Misc.getInt(excavation)
+ ", archery = archery+" + Misc.getInt(archery)
+ ", swords = swords+" + Misc.getInt(swords)
+ ", axes = axes+" + Misc.getInt(axes)
+ ", acrobatics = acrobatics+" + Misc.getInt(acrobatics)
+ ", fishing = fishing+" + Misc.getInt(fishing)
+ " taming = taming+" + StringUtils.getInt(taming)
+ ", mining = mining+" + StringUtils.getInt(mining)
+ ", repair = repair+" + StringUtils.getInt(repair)
+ ", woodcutting = woodcutting+" + StringUtils.getInt(woodcutting)
+ ", unarmed = unarmed+" + StringUtils.getInt(unarmed)
+ ", herbalism = herbalism+" + StringUtils.getInt(herbalism)
+ ", excavation = excavation+" + StringUtils.getInt(excavation)
+ ", archery = archery+" + StringUtils.getInt(archery)
+ ", swords = swords+" + StringUtils.getInt(swords)
+ ", axes = axes+" + StringUtils.getInt(axes)
+ ", acrobatics = acrobatics+" + StringUtils.getInt(acrobatics)
+ ", fishing = fishing+" + StringUtils.getInt(fishing)
+ " WHERE user_id = " + id);
Database.write("UPDATE "
+ tablePrefix
+ "experience SET "
+ " taming = " + Misc.getInt(tamingXP)
+ ", mining = " + Misc.getInt(miningXP)
+ ", repair = " + Misc.getInt(repairXP)
+ ", woodcutting = " + Misc.getInt(woodCuttingXP)
+ ", unarmed = " + Misc.getInt(unarmedXP)
+ ", herbalism = " + Misc.getInt(herbalismXP)
+ ", excavation = " + Misc.getInt(excavationXP)
+ ", archery = " + Misc.getInt(archeryXP)
+ ", swords = " + Misc.getInt(swordsXP)
+ ", axes = " + Misc.getInt(axesXP)
+ ", acrobatics = " + Misc.getInt(acrobaticsXP)
+ ", fishing = " + Misc.getInt(fishingXP)
+ " taming = " + StringUtils.getInt(tamingXP)
+ ", mining = " + StringUtils.getInt(miningXP)
+ ", repair = " + StringUtils.getInt(repairXP)
+ ", woodcutting = " + StringUtils.getInt(woodCuttingXP)
+ ", unarmed = " + StringUtils.getInt(unarmedXP)
+ ", herbalism = " + StringUtils.getInt(herbalismXP)
+ ", excavation = " + StringUtils.getInt(excavationXP)
+ ", archery = " + StringUtils.getInt(archeryXP)
+ ", swords = " + StringUtils.getInt(swordsXP)
+ ", axes = " + StringUtils.getInt(axesXP)
+ ", acrobatics = " + StringUtils.getInt(acrobaticsXP)
+ ", fishing = " + StringUtils.getInt(fishingXP)
+ " WHERE user_id = " + id);
}
}
System.out.println("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
mcMMO.p.getLogger().info("[mcMMO] MySQL Updated from users file, " + theCount + " items added/updated to MySQL DB");
in.close();
}
catch (Exception e) {

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.mods.datatypes.CustomTool;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.spout.huds.SpoutHud;
@@ -50,7 +51,7 @@ public class McMMOPlayer {
continue;
}
if (type.getPermissions(player)) {
if (Permissions.skillEnabled(player, type)) {
powerLevel += profile.getSkillLevel(type);
}
}
@@ -65,6 +66,10 @@ public class McMMOPlayer {
* @param xp Experience amount to process
*/
public void beginXpGain(SkillType skillType, int xp) {
if (xp == 0) {
return;
}
// Return if the experience has been shared
if (party != null && ShareHandler.handleXpShare(xp, this, skillType)) {
return;
@@ -82,10 +87,6 @@ public class McMMOPlayer {
public void beginUnsharedXpGain(SkillType skillType, int xp) {
xp = modifyXpGain(skillType, xp);
if (xp == 0) {
return;
}
applyXpGain(skillType, xp);
}
@@ -96,8 +97,14 @@ public class McMMOPlayer {
* @param xp Experience amount to add
*/
public void applyXpGain(SkillType skillType, int xp) {
mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + xp);
McMMOPlayerXpGainEvent event = new McMMOPlayerXpGainEvent(player, skillType, xp);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
profile.setSkillXpLevel(skillType, profile.getSkillXpLevel(skillType) + event.getXpGained());
SpoutHud spoutHud = profile.getSpoutHud();
@@ -120,7 +127,7 @@ public class McMMOPlayer {
return 0;
}
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Misc.getPowerLevelCap() < getPowerLevel() + 1)) {
if ((skillType.getMaxLevel() < profile.getSkillLevel(skillType) + 1) || (Config.getInstance().getPowerLevelCap() < getPowerLevel() + 1)) {
return 0;
}
@@ -135,23 +142,7 @@ public class McMMOPlayer {
}
}
// TODO: Too many permission checks here, is there no way to avoid that?
if (Permissions.xpQuadruple(player)) {
xp *= 4;
}
else if (Permissions.xpTriple(player)) {
xp *= 3;
}
else if (Permissions.xpDoubleAndOneHalf(player)) {
xp *= 2.5;
}
else if (Permissions.xpDouble(player)) {
xp *= 2;
}
else if (Permissions.xpOneAndOneHalf(player)) {
xp *= 1.5;
}
xp = PerksUtils.handleXpPerks(player, xp);
return xp;
}

View File

@@ -17,6 +17,7 @@ import com.gmail.nossr50.spout.SpoutConfig;
import com.gmail.nossr50.spout.huds.HudType;
import com.gmail.nossr50.spout.huds.SpoutHud;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public class PlayerProfile {
private String playerName;
@@ -36,6 +37,7 @@ public class PlayerProfile {
private boolean hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode,
pickaxePreparationMode, axePreparationMode;
private boolean abilityUse = true;
private boolean displaySkillNotifications = true;
// Timestamps
private long recentlyHurt;
@@ -128,7 +130,7 @@ public class PlayerProfile {
skillsDATS.put(AbilityType.GREEN_TERRA, Integer.valueOf(cooldownValues.get(3)));
skillsDATS.put(AbilityType.GIGA_DRILL_BREAKER, Integer.valueOf(cooldownValues.get(4)));
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(cooldownValues.get(5)));
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldownValues.get(6)));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(cooldownValues.get(6)));
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldownValues.get(7)));
}
@@ -205,49 +207,49 @@ public class PlayerProfile {
continue;
}
if (character.length > 1 && Misc.isInt(character[1]))
if (character.length > 1 && StringUtils.isInt(character[1]))
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
if (character.length > 4 && Misc.isInt(character[4]))
if (character.length > 4 && StringUtils.isInt(character[4]))
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
if (character.length > 5 && Misc.isInt(character[5]))
if (character.length > 5 && StringUtils.isInt(character[5]))
skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
if (character.length > 6 && Misc.isInt(character[6]))
if (character.length > 6 && StringUtils.isInt(character[6]))
skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
if (character.length > 7 && Misc.isInt(character[7]))
if (character.length > 7 && StringUtils.isInt(character[7]))
skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
if (character.length > 8 && Misc.isInt(character[8]))
if (character.length > 8 && StringUtils.isInt(character[8]))
skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
if (character.length > 9 && Misc.isInt(character[9]))
if (character.length > 9 && StringUtils.isInt(character[9]))
skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
if (character.length > 10 && Misc.isInt(character[10]))
if (character.length > 10 && StringUtils.isInt(character[10]))
skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
if (character.length > 11 && Misc.isInt(character[11]))
if (character.length > 11 && StringUtils.isInt(character[11]))
skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
if (character.length > 12 && Misc.isInt(character[12]))
if (character.length > 12 && StringUtils.isInt(character[12]))
skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
if (character.length > 13 && Misc.isInt(character[13]))
if (character.length > 13 && StringUtils.isInt(character[13]))
skills.put(SkillType.AXES, Integer.valueOf(character[13]));
if (character.length > 14 && Misc.isInt(character[14]))
if (character.length > 14 && StringUtils.isInt(character[14]))
skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
if (character.length > 15 && Misc.isInt(character[15]))
if (character.length > 15 && StringUtils.isInt(character[15]))
skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
if (character.length > 16 && Misc.isInt(character[16]))
if (character.length > 16 && StringUtils.isInt(character[16]))
skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
if (character.length > 17 && Misc.isInt(character[17]))
if (character.length > 17 && StringUtils.isInt(character[17]))
skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
if (character.length > 18 && Misc.isInt(character[18]))
if (character.length > 18 && StringUtils.isInt(character[18]))
skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
if (character.length > 19 && Misc.isInt(character[19]))
if (character.length > 19 && StringUtils.isInt(character[19]))
skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
if (character.length > 20 && Misc.isInt(character[20]))
if (character.length > 20 && StringUtils.isInt(character[20]))
skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
if (character.length > 21 && Misc.isInt(character[21]))
if (character.length > 21 && StringUtils.isInt(character[21]))
skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
if (character.length > 22 && Misc.isInt(character[22]))
if (character.length > 22 && StringUtils.isInt(character[22]))
skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
if (character.length > 24 && Misc.isInt(character[24]))
if (character.length > 24 && StringUtils.isInt(character[24]))
skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
if (character.length > 25 && Misc.isInt(character[25]))
if (character.length > 25 && StringUtils.isInt(character[25]))
skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
if (character.length > 26)
skillsDATS.put(AbilityType.BERSERK, Integer.valueOf(character[26]));
@@ -260,7 +262,7 @@ public class PlayerProfile {
if (character.length > 30)
skillsDATS.put(AbilityType.SERRATED_STRIKES, Integer.valueOf(character[30]));
if (character.length > 31)
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(character[31]));
skillsDATS.put(AbilityType.SKULL_SPLITTER, Integer.valueOf(character[31]));
if (character.length > 32)
skillsDATS.put(AbilityType.SUPER_BREAKER, Integer.valueOf(character[32]));
if (character.length > 33) {
@@ -306,7 +308,7 @@ public class PlayerProfile {
+ ", 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)
+ ", axes = " + skillsDATS.get(AbilityType.SKULL_SPLITTER)
+ ", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
+ " WHERE user_id = " + userId);
Database.write("UPDATE " + tablePrefix + "skills SET "
@@ -384,18 +386,18 @@ public class PlayerProfile {
writer.append(skillsXp.get(SkillType.TAMING)).append(":");
// 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))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.TREE_FELLER))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.GREEN_TERRA))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SERRATED_STRIKES))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SKULL_SPLIITER))).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.SUPER_BREAKER))).append(":");
writer.append(skillsDATS.get(AbilityType.BERSERK)).append(":");
writer.append(skillsDATS.get(AbilityType.GIGA_DRILL_BREAKER)).append(":");
writer.append(skillsDATS.get(AbilityType.TREE_FELLER)).append(":");
writer.append(skillsDATS.get(AbilityType.GREEN_TERRA)).append(":");
writer.append(skillsDATS.get(AbilityType.SERRATED_STRIKES)).append(":");
writer.append(skillsDATS.get(AbilityType.SKULL_SPLITTER)).append(":");
writer.append(skillsDATS.get(AbilityType.SUPER_BREAKER)).append(":");
writer.append(hudType.toString()).append(":");
writer.append(skills.get(SkillType.FISHING)).append(":");
writer.append(skillsXp.get(SkillType.FISHING)).append(":");
writer.append(String.valueOf(skillsDATS.get(AbilityType.BLAST_MINING))).append(":");
writer.append(String.valueOf(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)).append(":");
writer.append(skillsDATS.get(AbilityType.BLAST_MINING)).append(":");
writer.append(System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR).append(":");
writer.append("\r\n");
}
}
@@ -668,7 +670,7 @@ public class PlayerProfile {
case GREEN_TERRA:
return greenTerraMode;
case SKULL_SPLIITER:
case SKULL_SPLITTER:
return skullSplitterMode;
case TREE_FELLER:
@@ -706,7 +708,7 @@ public class PlayerProfile {
greenTerraMode = bool;
break;
case SKULL_SPLIITER:
case SKULL_SPLITTER:
skullSplitterMode = bool;
break;
@@ -746,7 +748,7 @@ public class PlayerProfile {
case GREEN_TERRA:
return greenTerraInformed;
case SKULL_SPLIITER:
case SKULL_SPLITTER:
return skullSplitterInformed;
case TREE_FELLER:
@@ -788,7 +790,7 @@ public class PlayerProfile {
greenTerraInformed = bool;
break;
case SKULL_SPLIITER:
case SKULL_SPLITTER:
skullSplitterInformed = bool;
break;
@@ -829,6 +831,18 @@ public class PlayerProfile {
respawnATS = (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR);
}
/*
* Ability Notifications
*/
public boolean useChatNotifications() {
return displaySkillNotifications;
}
public void toggleChatNotifications() {
displaySkillNotifications = !displaySkillNotifications;
}
/*
* Cooldowns
*/

View File

@@ -5,7 +5,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.Plugin;
public class McMMOChatEvent extends Event implements Cancellable {
public abstract class McMMOChatEvent extends Event implements Cancellable {
private boolean cancelled;
private Plugin plugin;
private String sender;

View File

@@ -1,22 +1,25 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Users;
/**
* Generic event for mcMMO experience events.
*/
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent {
public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements Cancellable {
private boolean cancelled;
protected SkillType skill;
protected int skillLevel;
protected McMMOPlayerExperienceEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = skill.getSkillLevel(player);
this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
}
/**
@@ -44,4 +47,15 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent {
public static HandlerList getHandlerList() {
return handlers;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

View File

@@ -12,7 +12,12 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
super(player, skill);
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
this.levelsGained = 1;
}
public McMMOPlayerLevelUpEvent(Player player, SkillType skill, int levelsGained) {
super(player, skill);
this.levelsGained = levelsGained;
}
/**

View File

@@ -21,4 +21,11 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
public int getXpGained() {
return xpGained;
}
/**
* @param xpGained int amount of experience gained in this event
*/
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
}

View File

@@ -5,6 +5,7 @@ import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Users;
/**
* Generic event for mcMMO skill handling.
@@ -16,7 +17,7 @@ public abstract class McMMOPlayerSkillEvent extends PlayerEvent {
protected McMMOPlayerSkillEvent(Player player, SkillType skill) {
super(player);
this.skill = skill;
this.skillLevel = skill.getSkillLevel(player);
this.skillLevel = Users.getPlayer(player).getProfile().getSkillLevel(skill);
}
/**

View File

@@ -22,6 +22,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
@@ -30,11 +31,11 @@ import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.runnables.StickyPistonTracker;
import com.gmail.nossr50.skills.excavation.Excavation;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Salvage;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
@@ -103,7 +104,7 @@ public class BlockListener implements Listener {
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -139,7 +140,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -159,31 +160,27 @@ public class BlockListener implements Listener {
* We don't check the block store here because herbalism has too many unusual edge cases.
* Instead, we check it inside the drops handler.
*/
if (Permissions.herbalism(player)) {
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Double drops
if (Permissions.skillEnabled(player, SkillType.HERBALISM)) {
Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Double drops
if (profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
Herbalism.herbalismProcCheck(block, mcMMOPlayer, event, plugin); //Triple drops
Herbalism.herbalismProcCheck(block, mcMMOPlayer, plugin); //Triple drops
}
}
}
/* MINING */
else if (BlockChecks.canBeSuperBroken(block) && Permissions.mining(player) && !mcMMO.placeStore.isTrue(block)) {
if (Mining.requiresTool) {
if (ItemChecks.isPickaxe(heldItem)) {
MiningManager miningManager = new MiningManager(mcMMOPlayer);
miningManager.miningBlockCheck(block);
}
}
else {
MiningManager miningManager = new MiningManager(mcMMOPlayer);
else if (BlockChecks.canBeSuperBroken(block) && ItemChecks.isPickaxe(heldItem) && Permissions.skillEnabled(player, SkillType.MINING) && !mcMMO.placeStore.isTrue(block)) {
MiningManager miningManager = new MiningManager(mcMMOPlayer);
miningManager.miningBlockCheck(block);
if (profile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
miningManager.miningBlockCheck(block);
}
}
/* WOOD CUTTING */
else if (BlockChecks.isLog(block) && Permissions.woodcutting(player) && !mcMMO.placeStore.isTrue(block)) {
else if (BlockChecks.isLog(block) && Permissions.skillEnabled(player, SkillType.WOODCUTTING) && !mcMMO.placeStore.isTrue(block)) {
if (profile.getAbilityMode(AbilityType.TREE_FELLER) && Permissions.treeFeller(player) && ItemChecks.isAxe(heldItem)) {
Woodcutting.beginTreeFeller(mcMMOPlayer, block);
}
@@ -200,14 +197,11 @@ public class BlockListener implements Listener {
}
/* EXCAVATION */
else if (BlockChecks.canBeGigaDrillBroken(block) && Permissions.excavation(player) && !mcMMO.placeStore.isTrue(block)) {
if (Excavation.requiresTool) {
if (ItemChecks.isShovel(heldItem)) {
Excavation.excavationProcCheck(block, mcMMOPlayer);
}
}
else {
Excavation.excavationProcCheck(block, mcMMOPlayer);
else if (BlockChecks.canBeGigaDrillBroken(block) && ItemChecks.isShovel(heldItem) && Permissions.skillEnabled(player, SkillType.EXCAVATION) && !mcMMO.placeStore.isTrue(block)) {
Excavation.excavationProcCheck(block, mcMMOPlayer);
if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER)) {
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
}
}
@@ -230,7 +224,7 @@ public class BlockListener implements Listener {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -247,19 +241,19 @@ public class BlockListener implements Listener {
}
/**
* Handle BlockDamage events where the event is modified.
* Monitor BlockDamage events.
*
* @param event The event to modify
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) {
return;
}
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -274,6 +268,17 @@ public class BlockListener implements Listener {
if (BlockChecks.canActivateAbilities(block)) {
ItemStack heldItem = player.getItemInHand();
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemChecks.isPickaxe(heldItem) && !profile.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemChecks.isShovel(heldItem) && !profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
SkillTools.removeAbilityBuff(heldItem);
}
}
else {
if ((profile.getAbilityMode(AbilityType.SUPER_BREAKER) && !BlockChecks.canBeSuperBroken(block)) || (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && !BlockChecks.canBeGigaDrillBroken(block))) {
SkillTools.handleAbilitySpeedDecrease(player);
}
}
if (profile.getToolPreparationMode(ToolType.HOE) && ItemChecks.isHoe(heldItem) && (BlockChecks.canBeGreenTerra(block) || BlockChecks.canMakeMossy(block)) && Permissions.greenTerra(player)) {
SkillTools.abilityCheck(player, SkillType.HERBALISM);
}
@@ -286,7 +291,7 @@ public class BlockListener implements Listener {
else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) {
SkillTools.abilityCheck(player, SkillType.EXCAVATION);
}
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW) && Permissions.berserk(player)) {
else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW || (block.getType() == Material.SMOOTH_BRICK && block.getData() == 0x0)) && Permissions.berserk(player)) {
SkillTools.abilityCheck(player, SkillType.UNARMED);
}
}
@@ -302,19 +307,19 @@ public class BlockListener implements Listener {
}
/**
* Monitor BlockDamage events.
* Handle BlockDamage events where the event is modified.
*
* @param event The event to watch
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamageHigher(BlockDamageEvent event) {
if (event instanceof FakeBlockDamageEvent) {
return;
}
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -331,40 +336,19 @@ public class BlockListener implements Listener {
if (profile.getAbilityMode(AbilityType.GREEN_TERRA) && BlockChecks.canMakeMossy(block)) {
Herbalism.greenTerra(player, block);
}
else if (profile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
if (Excavation.requiresTool) {
if (ItemChecks.isShovel(heldItem)) {
else if (profile.getAbilityMode(AbilityType.BERSERK)) {
if (SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
if (heldItem.getType() == Material.AIR) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
plugin.getServer().getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
}
}
else {
event.setInstaBreak(true);
Excavation.gigaDrillBreaker(mcMMOPlayer, block);
}
}
else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) {
if (heldItem.getType() == Material.AIR) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
plugin.getServer().getPluginManager().callEvent(armswing);
event.setInstaBreak(true);
}
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
}
else if (profile.getAbilityMode(AbilityType.SUPER_BREAKER) && SkillTools.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
MiningManager miningManager = new MiningManager(mcMMOPlayer);
if (Mining.requiresTool) {
if (ItemChecks.isPickaxe(heldItem)) {
event.setInstaBreak(true);
miningManager.superBreakerBlockCheck(block);
}
}
else {
event.setInstaBreak(true);
miningManager.superBreakerBlockCheck(block);
// Another perm check for the cracked blocks activation
else if (BlockChecks.canBeCracked(block) && Permissions.blockCracker(player)) {
Unarmed.blockCracker(player, block);
}
}
else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) {

View File

@@ -65,13 +65,12 @@ public class EntityListener implements Listener {
if (entity instanceof FallingBlock) {
Block block = event.getBlock();
if (mcMMO.placeStore.isTrue(block) && !mcMMO.placeStore.isSpawnedMob(entity)) {
if (mcMMO.placeStore.isTrue(block) && !entity.hasMetadata(mcMMO.entityMetadataKey)) {
mcMMO.placeStore.setFalse(block);
mcMMO.placeStore.addSpawnedMob(entity);
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.entityMetadata);
}
else if (mcMMO.placeStore.isSpawnedMob(entity)) {
else if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
mcMMO.placeStore.setTrue(block);
mcMMO.placeStore.removeSpawnedMob(entity);
}
}
}
@@ -108,15 +107,23 @@ public class EntityListener implements Listener {
if (defender instanceof Player) {
Player defendingPlayer = (Player) defender;
// TODO: Is this even possible?
if (!defendingPlayer.isOnline()) {
return;
}
if (attacker instanceof Player && PartyManager.inSameParty(defendingPlayer, (Player) attacker)) {
if (!(Permissions.friendlyFire((Player) attacker) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
if (attacker instanceof Player) {
Player attackingPlayer = (Player) attacker;
if (defendingPlayer == attackingPlayer) {
return;
}
else if (PartyManager.inSameParty(defendingPlayer, attackingPlayer)) {
if (!(Permissions.friendlyFire(attackingPlayer) && Permissions.friendlyFire(defendingPlayer))) {
event.setCancelled(true);
return;
}
}
}
}
@@ -124,7 +131,7 @@ public class EntityListener implements Listener {
if (defender instanceof LivingEntity) {
LivingEntity livingDefender = (LivingEntity) defender;
if (!Misc.isInvincible(livingDefender, event)) {
if (!CombatTools.isInvincible(livingDefender, event)) {
CombatTools.combatChecks(event, attacker, livingDefender);
}
}
@@ -153,7 +160,7 @@ public class EntityListener implements Listener {
if (livingEntity instanceof Player) {
Player player = (Player) entity;
if (!player.isOnline() || Misc.isNPCPlayer(player)) {
if (!player.isOnline() || Misc.isNPCEntity(player)) {
return;
}
@@ -166,7 +173,7 @@ public class EntityListener implements Listener {
return;
}
if (!Misc.isInvincible(player, event)) {
if (!CombatTools.isInvincible(player, event)) {
if (cause == DamageCause.FALL && player.getItemInHand().getType() != Material.ENDER_PEARL && !(Acrobatics.afkLevelingDisabled && player.isInsideVehicle()) && Permissions.roll(player)) {
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(mcMMOPlayer);
acrobaticsManager.rollCheck(event);
@@ -185,7 +192,7 @@ public class EntityListener implements Listener {
Tameable pet = (Tameable) livingEntity;
AnimalTamer owner = pet.getOwner();
if ((!Misc.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
if ((!CombatTools.isInvincible(livingEntity, event)) && pet.isTamed() && owner instanceof Player && pet instanceof Wolf) {
TamingManager tamingManager = new TamingManager(Users.getPlayer((Player) owner));
tamingManager.preventDamage(event);
}
@@ -208,7 +215,6 @@ public class EntityListener implements Listener {
entity.setFireTicks(0);
BleedTimer.remove(entity);
Archery.arrowRetrievalCheck(entity);
mcMMO.placeStore.removeSpawnedMob(entity);
}
/**
@@ -221,11 +227,14 @@ public class EntityListener implements Listener {
if (Misc.isSpawnerXPEnabled) {
return;
}
else if (event.getEntity() == null) {
return;
}
SpawnReason reason = event.getSpawnReason();
if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) {
mcMMO.placeStore.addSpawnedMob(event.getEntity());
event.getEntity().setMetadata(mcMMO.entityMetadataKey, mcMMO.entityMetadata);
}
}
@@ -287,7 +296,7 @@ public class EntityListener implements Listener {
if (entity instanceof Player) {
Player player = (Player) entity;
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -343,7 +352,7 @@ public class EntityListener implements Listener {
public void onEntityTame(EntityTameEvent event) {
Player player = (Player) event.getOwner();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -351,13 +360,13 @@ public class EntityListener implements Listener {
tamingManager.awardTamingXP(event);
}
@EventHandler (ignoreCancelled = true)
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(EntityTargetEvent event) {
if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) {
Player player = (Player) event.getTarget();
Tameable tameable = (Tameable) event.getEntity();
if (Misc.isFriendlyPet(player, tameable)) {
if (CombatTools.isFriendlyPet(player, tameable)) {
// isFriendlyPet ensures that the Tameable is: Tamed, owned by a player, and the owner is in the same party
// So we can make some assumptions here, about our casting and our check
Player owner = (Player) tameable.getOwner();

View File

@@ -1,37 +0,0 @@
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.util.Hardcore;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class HardcoreListener implements Listener {
/**
* Monitor PlayerDeath events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
if (Misc.isNPCPlayer(player)) {
return;
}
if (!Permissions.hardcoremodeBypass(player)) {
Player killer = player.getKiller();
if (killer != null && Hardcore.vampirismEnabled) {
Hardcore.invokeVampirism(killer, player);
}
Hardcore.invokeStatPenalty(player);
}
}
}

View File

@@ -3,17 +3,23 @@ package com.gmail.nossr50.listeners;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerLoginEvent.Result;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.inventory.ItemStack;
@@ -26,6 +32,7 @@ import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.skills.fishing.Fishing;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.mining.BlastMining;
@@ -34,11 +41,15 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Salvage;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.BlockChecks;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.Hardcore;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
@@ -49,6 +60,34 @@ public class PlayerListener implements Listener {
this.plugin = plugin;
}
/**
* Monitor PlayerDeath events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDeath(PlayerDeathEvent event) {
if (!Config.getInstance().getHardcoreEnabled()) {
return;
}
Player player = event.getEntity();
if (Misc.isNPCEntity(player)) {
return;
}
if (!Permissions.hardcoreBypass(player)) {
Player killer = player.getKiller();
if (killer != null && Config.getInstance().getHardcoreVampirismEnabled()) {
Hardcore.invokeVampirism(killer, player);
}
Hardcore.invokeStatPenalty(player);
}
}
/**
* Monitor PlayerChangedWorld events.
*
@@ -58,7 +97,7 @@ public class PlayerListener implements Listener {
public void onPlayerWorldChangeEvent(PlayerChangedWorldEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -76,6 +115,39 @@ public class PlayerListener implements Listener {
}
}
/**
* Monitor PlayerLogin events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerLoginEvent(PlayerLoginEvent event) {
if (event.getResult() == Result.ALLOWED) {
Player player = event.getPlayer();
if (Misc.isNPCEntity(player)) {
return;
}
Users.addUser(player).getProfile().actualizeRespawnATS();
}
}
/**
* Handle PlayerDropItem events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
Player player = event.getPlayer();
PlayerProfile playerProfile = Users.getPlayer(player).getProfile();
if (playerProfile.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) || playerProfile.getAbilityMode(AbilityType.SUPER_BREAKER)) {
event.setCancelled(true);
}
}
/**
* Monitor PlayerFish events.
*
@@ -85,7 +157,7 @@ public class PlayerListener implements Listener {
public void onPlayerFish(PlayerFishEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player) || !Permissions.fishing(player)) {
if (Misc.isNPCEntity(player) || !Permissions.skillEnabled(player, SkillType.FISHING)) {
return;
}
@@ -100,7 +172,7 @@ public class PlayerListener implements Listener {
case CAUGHT_ENTITY:
Entity entity = event.getCaught();
if (entity instanceof LivingEntity && skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shakeMob(player)) {
if (entity instanceof LivingEntity && skillLevel >= AdvancedConfig.getInstance().getShakeUnlockLevel() && Permissions.shake(player)) {
Fishing.beginShakeMob(player, (LivingEntity) entity, skillLevel);
}
@@ -110,6 +182,27 @@ public class PlayerListener implements Listener {
}
}
/**
* Monitor PlayerPickupItem events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
Item item = event.getItem();
if (Misc.isNPCEntity(player)) {
return;
}
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
if (mcMMOPlayer.inParty() && ItemChecks.isShareable(item.getItemStack())) {
ShareHandler.handleItemShare(event, mcMMOPlayer);
}
}
/**
* Monitor PlayerQuit events.
*
@@ -119,7 +212,7 @@ public class PlayerListener implements Listener {
public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -136,13 +229,6 @@ public class PlayerListener implements Listener {
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
/* We can't use the other check here because a profile hasn't been created yet.*/
if (player == null || player.hasMetadata("NPC")) {
return;
}
Users.addUser(player).getProfile().actualizeRespawnATS();
if (Config.getInstance().getMOTDEnabled() && Permissions.motd(player)) {
Motd.displayAll(player);
}
@@ -150,6 +236,11 @@ public class PlayerListener implements Listener {
if (plugin.isXPEventEnabled()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", Config.getInstance().getExperienceGainsGlobalMultiplier()));
}
if (Permissions.updateNotifications(player) && mcMMO.p.updateAvailable) {
player.sendMessage(LocaleLoader.getString("UpdateChecker.outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.newavailable"));
}
}
/**
@@ -160,7 +251,7 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -176,7 +267,7 @@ public class PlayerListener implements Listener {
public void onPlayerInteractLowest(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -188,7 +279,7 @@ public class PlayerListener implements Listener {
int blockID = block.getTypeId();
/* REPAIR CHECKS */
if (blockID == Repair.anvilID && Permissions.repair(player) && mcMMO.repairManager.isRepairable(heldItem)) {
if (blockID == Repair.anvilID && Permissions.skillEnabled(player, SkillType.REPAIR) && mcMMO.repairManager.isRepairable(heldItem)) {
mcMMO.repairManager.handleRepair(Users.getPlayer(player), heldItem);
event.setCancelled(true);
player.updateInventory();
@@ -200,7 +291,7 @@ public class PlayerListener implements Listener {
player.updateInventory();
}
/* BLAST MINING CHECK */
else if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
else if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
miningManager.detonate(event);
}
@@ -209,7 +300,7 @@ public class PlayerListener implements Listener {
case RIGHT_CLICK_AIR:
/* BLAST MINING CHECK */
if (player.isSneaking() && Permissions.blastMining(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
if (player.isSneaking() && Permissions.remoteDetonation(player) && heldItem.getTypeId() == BlastMining.detonatorID) {
MiningManager miningManager = new MiningManager(Users.getPlayer(player));
miningManager.detonate(event);
}
@@ -230,7 +321,7 @@ public class PlayerListener implements Listener {
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -254,10 +345,12 @@ public class PlayerListener implements Listener {
SkillTools.activationCheck(player, SkillType.UNARMED);
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
}
ChimaeraWing.activationCheck(player);
}
/* GREEN THUMB CHECK */
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block) && Permissions.greenThumbBlocks(player)) {
if (heldItem.getType() == Material.SEEDS && BlockChecks.canMakeMossy(block)) {
Herbalism.greenThumbBlocks(heldItem, player, block);
}
@@ -276,6 +369,9 @@ public class PlayerListener implements Listener {
SkillTools.activationCheck(player, SkillType.WOODCUTTING);
}
/* ITEM CHECKS */
ChimaeraWing.activationCheck(player);
break;
case LEFT_CLICK_AIR:
@@ -311,7 +407,7 @@ public class PlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
if (Misc.isNPCPlayer(player)) {
if (Misc.isNPCEntity(player)) {
return;
}
@@ -346,16 +442,17 @@ public class PlayerListener implements Listener {
String command = message.substring(1).split(" ")[0];
String lowerCaseCommand = command.toLowerCase();
// Do these ACTUALLY have to be lower case to work properly?
for (SkillType skill : SkillType.values()) {
String commandName = skill.toString().toLowerCase();
String localizedName = LocaleLoader.getString(Misc.getCapitalized(commandName) + ".SkillName").toLowerCase();
String skillName = skill.toString().toLowerCase();
String localizedName = SkillTools.getSkillName(skill).toLowerCase();
if (lowerCaseCommand.equals(localizedName)) {
event.setMessage(message.replace(command, skillName));
break;
}
if (lowerCaseCommand.equals(commandName)) {
event.setMessage(message.replace(command, localizedName));
if (lowerCaseCommand.equals(skillName)) {
break;
}
}

View File

@@ -1,8 +1,10 @@
package com.gmail.nossr50.listeners;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
/**
@@ -14,7 +16,7 @@ public class SelfListener implements Listener {
*
* @param event The event to watch
*/
@EventHandler
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
int xp = event.getXpGained();
@@ -23,7 +25,7 @@ public class SelfListener implements Listener {
throw new Exception("Gained negative XP!");
}
catch (Exception e) {
System.out.println(e.getMessage());
mcMMO.p.getLogger().severe(e.getMessage());
e.printStackTrace();
}
}

View File

@@ -7,13 +7,9 @@ import org.bukkit.Chunk;
import org.bukkit.TreeType;
import org.bukkit.World;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.event.world.WorldInitEvent;
@@ -87,22 +83,4 @@ public class WorldListener implements Listener {
mcMMO.placeStore.chunkUnloaded(chunk.getX(), chunk.getZ(), event.getWorld());
}
/**
* Monitor ChunkLoad events.
*
* @param event The event to watch
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
Chunk chunk = event.getChunk();
Entity[] entities = chunk.getEntities();
for (Entity entity : entities) {
if (entity instanceof LivingEntity || entity instanceof FallingBlock) {
mcMMO.placeStore.loadChunk(chunk.getX(), chunk.getZ(), event.getWorld(), entities);
return;
}
}
}
}

View File

@@ -12,6 +12,7 @@ import com.gmail.nossr50.config.Config;
public final class LocaleLoader {
private static final String BUNDLE_ROOT = "com.gmail.nossr50.locale.locale";
private static ResourceBundle bundle = null;
private static ResourceBundle enBundle = null;
private LocaleLoader() {};
@@ -32,21 +33,30 @@ public final class LocaleLoader {
}
try {
String output = bundle.getString(key);
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
return getString(key, bundle, messageArguments);
}
catch (MissingResourceException ex) {
try {
return getString(key, enBundle, messageArguments);
}
catch (MissingResourceException ex2) {
return '!' + key + '!';
}
output = addColors(output);
return output;
}
catch (MissingResourceException e) {
return '!' + key + '!';
}
private static String getString(String key, ResourceBundle bundle, Object ... messageArguments) throws MissingResourceException {
String output = bundle.getString(key);
if (messageArguments != null) {
MessageFormat formatter = new MessageFormat("");
formatter.applyPattern(output);
output = formatter.format(messageArguments);
}
output = addColors(output);
return output;
}
public static Locale getCurrentLocale() {
@@ -70,6 +80,7 @@ public final class LocaleLoader {
}
bundle = ResourceBundle.getBundle(BUNDLE_ROOT, locale);
enBundle = ResourceBundle.getBundle(BUNDLE_ROOT, Locale.US);
}
}

View File

@@ -1,29 +1,25 @@
package com.gmail.nossr50;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitScheduler;
import org.mcstats.Metrics;
import org.mcstats.Metrics.Graph;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.metrics.MetricsManager;
import com.gmail.nossr50.commands.CommandRegistrationHelper;
import com.gmail.nossr50.commands.player.MccCommand;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
@@ -34,7 +30,6 @@ import com.gmail.nossr50.database.runnables.UserPurgeTask;
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.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.WorldListener;
@@ -44,18 +39,20 @@ import com.gmail.nossr50.mods.config.CustomBlocksConfig;
import com.gmail.nossr50.mods.config.CustomEntityConfig;
import com.gmail.nossr50.mods.config.CustomToolsConfig;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.commands.PtpCommand;
import com.gmail.nossr50.runnables.MobStoreCleaner;
import com.gmail.nossr50.party.runnables.PartiesLoader;
import com.gmail.nossr50.party.runnables.PartyAutoKick;
import com.gmail.nossr50.runnables.SaveTimer;
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.skills.repair.config.RepairConfigManager;
import com.gmail.nossr50.skills.runnables.BleedTimer;
import com.gmail.nossr50.skills.runnables.PartyAutoKick;
import com.gmail.nossr50.skills.runnables.SkillMonitor;
import com.gmail.nossr50.spout.SpoutConfig;
import com.gmail.nossr50.spout.SpoutTools;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.UpdateCheck;
import com.gmail.nossr50.util.Users;
public class mcMMO extends JavaPlugin {
@@ -64,7 +61,6 @@ public class mcMMO extends JavaPlugin {
private final EntityListener entityListener = new EntityListener(this);
private final InventoryListener inventoryListener = new InventoryListener(this);
private final WorldListener worldListener = new WorldListener();
private final HardcoreListener hardcoreListener = new HardcoreListener();
private HashMap<Integer, String> tntTracker = new HashMap<Integer, String>();
private HashMap<Block, String> furnaceTracker = new HashMap<Block, String>();
@@ -83,18 +79,27 @@ public class mcMMO extends JavaPlugin {
private static String usersFile;
private static String modDirectory;
// Update Check
public boolean updateAvailable;
// Spout Check
public static boolean spoutEnabled = false;
// XP Event Check
private boolean xpEventEnabled = false;
// Entity Metadata Values
public static FixedMetadataValue entityMetadata;
public final static String entityMetadataKey = "mcMMO: Spawned Entity";
/**
* Things to be run when the plugin is enabled.
*/
@Override
public void onEnable() {
p = this;
getLogger().setFilter(new LogFilter(this));
entityMetadata = new FixedMetadataValue(mcMMO.p, true);
setupFilePaths();
setupSpout();
loadConfigFiles();
@@ -123,11 +128,16 @@ public class mcMMO extends JavaPlugin {
scheduleTasks();
registerCommands();
setupMetrics();
MetricsManager.setup();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
new MobStoreCleaner(); // Automatically starts and stores itself
checkForUpdates();
if (Config.getInstance().getPTPCommandWorldPermissions()) {
Permissions.generateWorldTeleportPermissions();
}
}
/**
@@ -141,6 +151,22 @@ public class mcMMO extends JavaPlugin {
modDirectory = mainDirectory + "ModConfigs" + File.separator;
}
private void checkForUpdates() {
if (Config.getInstance().getUpdateCheckEnabled()) {
try {
updateAvailable = UpdateCheck.updateAvailable();
}
catch (Exception e) {
updateAvailable = false;
}
if (updateAvailable) {
getLogger().info(LocaleLoader.getString("UpdateChecker.outdated"));
getLogger().info(LocaleLoader.getString("UpdateChecker.newavailable"));
}
}
}
/**
* Get profile of the player by name.
* </br>
@@ -189,12 +215,14 @@ public class mcMMO extends JavaPlugin {
placeStore.saveAll(); // Save our metadata
placeStore.cleanUp(); // Cleanup empty metadata stores
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
ZipLibrary.mcMMObackup();
}
catch (IOException e) {
getLogger().severe(e.toString());
if (Config.getInstance().getBackupsEnabled()) {
// Remove other tasks BEFORE starting the Backup, or we just cancel it straight away.
try {
ZipLibrary.mcMMObackup();
}
catch (IOException e) {
getLogger().severe(e.toString());
}
}
getLogger().info("Was disabled."); //How informative!
@@ -206,7 +234,8 @@ public class mcMMO extends JavaPlugin {
TreasuresConfig.getInstance();
HiddenConfig.getInstance();
AdvancedConfig.getInstance();
PartyManager.loadParties();
List<Repairable> repairables = new ArrayList<Repairable>();
@@ -260,10 +289,6 @@ public class mcMMO extends JavaPlugin {
pluginManager.registerEvents(entityListener, this);
pluginManager.registerEvents(inventoryListener, this);
pluginManager.registerEvents(worldListener, this);
if (Config.getInstance().getHardcoreEnabled()) {
pluginManager.registerEvents(hardcoreListener, this);
}
}
/**
@@ -276,7 +301,6 @@ public class mcMMO extends JavaPlugin {
CommandRegistrationHelper.registerMcpurgeCommand();
CommandRegistrationHelper.registerMcremoveCommand();
CommandRegistrationHelper.registerMcabilityCommand();
getCommand("mcc").setExecutor(new MccCommand());
CommandRegistrationHelper.registerMcgodCommand();
CommandRegistrationHelper.registerMcmmoCommand();
CommandRegistrationHelper.registerMcrefreshCommand();
@@ -288,7 +312,7 @@ public class mcMMO extends JavaPlugin {
CommandRegistrationHelper.registerAdminChatCommand();
CommandRegistrationHelper.registerPartyCommand();
CommandRegistrationHelper.registerPartyChatCommand();
getCommand("ptp").setExecutor(new PtpCommand(this));
CommandRegistrationHelper.registerPtpCommand();
// Other commands
CommandRegistrationHelper.registerAddxpCommand();
@@ -298,6 +322,9 @@ public class mcMMO extends JavaPlugin {
CommandRegistrationHelper.registerXprateCommand();
CommandRegistrationHelper.registerMmoupdateCommand();
CommandRegistrationHelper.registerSkillresetCommand();
CommandRegistrationHelper.registerHardcoreCommand();
CommandRegistrationHelper.registerVampirismCommand();
CommandRegistrationHelper.registerMcnotifyCommand();
// Spout commands
CommandRegistrationHelper.registerXplockCommand();
@@ -307,12 +334,17 @@ public class mcMMO extends JavaPlugin {
private void scheduleTasks() {
BukkitScheduler scheduler = getServer().getScheduler();
// Parties are loaded at the end of first server tick otherwise Server.getOfflinePlayer throws an IndexOutOfBoundsException
scheduler.scheduleSyncDelayedTask(this, new PartiesLoader(), 0);
// Periodic save timer (Saves every 10 minutes by default)
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), 0, Config.getInstance().getSaveInterval() * 1200L);
long saveIntervalTicks = Config.getInstance().getSaveInterval() * 1200;
scheduler.scheduleSyncRepeatingTask(this, new SaveTimer(), saveIntervalTicks, saveIntervalTicks);
// Regen & Cooldown timer (Runs every second)
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 0, 20);
scheduler.scheduleSyncRepeatingTask(this, new SkillMonitor(), 20, 20);
// Bleed timer (Runs every two seconds)
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 0, 40);
scheduler.scheduleSyncRepeatingTask(this, new BleedTimer(), 40, 40);
// Old & Powerless User remover
int purgeInterval = Config.getInstance().getPurgeInterval();
@@ -321,7 +353,9 @@ public class mcMMO extends JavaPlugin {
scheduler.scheduleSyncDelayedTask(this, new UserPurgeTask(), 40); // Start 2 seconds after startup.
}
else if (purgeInterval > 0) {
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), 0, purgeInterval * 60L * 60L * 20L);
long purgeIntervalTicks = purgeInterval * 60 * 60 * 20;
scheduler.scheduleSyncRepeatingTask(this, new UserPurgeTask(), purgeIntervalTicks, purgeIntervalTicks);
}
// Automatically remove old members from parties
@@ -331,158 +365,12 @@ public class mcMMO extends JavaPlugin {
scheduler.scheduleSyncDelayedTask(this, new PartyAutoKick(), 40); // Start 2 seconds after startup.
}
else if (kickInterval > 0) {
scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKick(), 0, kickInterval * 60L * 60L * 20L);
long kickIntervalTicks = kickInterval * 60 * 60 * 20;
scheduler.scheduleSyncRepeatingTask(this, new PartyAutoKick(), kickIntervalTicks, kickIntervalTicks);
}
}
private void setupMetrics() {
if (Config.getInstance().getStatsTrackingEnabled()) {
try {
Metrics metrics = new Metrics(this);
// Timings Graph
Graph timingsGraph = metrics.createGraph("Percentage of servers using timings");
if (getServer().getPluginManager().useTimings()) {
timingsGraph.addPlotter(new Metrics.Plotter("Enabled") {
@Override
public int getValue() {
return 1;
}
});
}
else {
timingsGraph.addPlotter(new Metrics.Plotter("Disabled") {
@Override
public int getValue() {
return 1;
}
});
}
// Donut Version Graph
Graph versionDonutGraph = metrics.createGraph("Donut Version");
boolean haveVersionInformation = false;
boolean isOfficialBuild = false;
String officialKey = "e14cfacdd442a953343ebd8529138680";
String version = getDescription().getVersion();
InputStreamReader isr = new InputStreamReader(getResource(".jenkins"));
BufferedReader br = new BufferedReader(isr);
char[] key = new char[32];
br.read(key);
if (officialKey.equals(String.valueOf(key))) {
isOfficialBuild = true;
}
if (version.contains("-")) {
String majorVersion = version.substring(0, version.indexOf("-"));
String subVersion = "";
if (isOfficialBuild) {
int startIndex = version.indexOf("-");
if (version.substring(startIndex + 1).contains("-")) {
subVersion = version.substring(startIndex, version.indexOf("-", startIndex + 1));
} else {
subVersion = "-release";
}
} else {
subVersion = "-custom";
}
version = majorVersion + "~=~" + subVersion;
haveVersionInformation = true;
} else {
haveVersionInformation = false;
}
if (haveVersionInformation) {
versionDonutGraph.addPlotter(new Metrics.Plotter(version) {
@Override
public int getValue() {
return 1;
}
});
}
// Official v Custom build Graph
Graph officialGraph = metrics.createGraph("Built by official ci");
if (isOfficialBuild) {
officialGraph.addPlotter(new Metrics.Plotter("Yes") {
@Override
public int getValue() {
return 1;
}
});
}
else {
officialGraph.addPlotter(new Metrics.Plotter("No") {
@Override
public int getValue() {
return 1;
}
});
}
// Chunkmeta enabled Graph
Graph chunkmetaGraph = metrics.createGraph("Uses Chunkmeta");
if (HiddenConfig.getInstance().getChunkletsEnabled()) {
chunkmetaGraph.addPlotter(new Metrics.Plotter("Yes") {
@Override
public int getValue() {
return 1;
}
});
}
else {
chunkmetaGraph.addPlotter(new Metrics.Plotter("No") {
@Override
public int getValue() {
return 1;
}
});
}
// Storage method Graph
Graph storageGraph = metrics.createGraph("Storage method");
if (Config.getInstance().getUseMySQL()) {
storageGraph.addPlotter(new Metrics.Plotter("SQL") {
@Override
public int getValue() {
return 1;
}
});
}
else {
storageGraph.addPlotter(new Metrics.Plotter("Flatfile") {
@Override
public int getValue() {
return 1;
}
});
}
// Locale Graph
Graph localeGraph = metrics.createGraph("Locale");
localeGraph.addPlotter(new Metrics.Plotter(LocaleLoader.getCurrentLocale().getDisplayLanguage(Locale.US)) {
@Override
public int getValue() {
return 1;
}
});
metrics.start();
}
catch (IOException e) {
System.out.println("Failed to submit stats.");
}
}
}
/**
* Add a set of values to the TNT tracker.
*
@@ -565,4 +453,8 @@ public class mcMMO extends JavaPlugin {
public void toggleXpEventEnabled() {
xpEventEnabled = !xpEventEnabled;
}
public void debug(String message) {
getLogger().info("[Debug] " + message);
}
}

View File

@@ -51,6 +51,10 @@ public final class ModChecks {
* @return the block if it exists, null otherwise
*/
public static CustomBlock getCustomBlock(Block block) {
if (!Config.getInstance().getBlockModsEnabled()) {
return null;
}
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
if (!CustomBlocksConfig.getInstance().customItems.contains(item)) {
@@ -79,8 +83,9 @@ public final class ModChecks {
return null;
}
/**
* Check if a custom block is a custom block.
* Check if a custom block is a mining block.
*
* @param block The block to check
* @return true if the block is custom, false otherwise
@@ -99,6 +104,26 @@ public final class ModChecks {
return false;
}
/**
* Check if a custom block is a mining block.
*
* @param block The block to check
* @return true if the block is custom, false otherwise
*/
public static boolean isCustomExcavationBlock(Block block) {
ItemStack item = (new MaterialData(block.getTypeId(), block.getData())).toItemStack(1);
if (customBlocksEnabled && CustomBlocksConfig.getInstance().customExcavationBlocks.contains(item)) {
for (CustomBlock b : CustomBlocksConfig.getInstance().customBlocks) {
if ((b.getItemID() == block.getTypeId()) && (b.getDataValue() == block.getData())) {
return true;
}
}
}
return false;
}
/**
* Check if a custom block is a leaf block.
*

View File

@@ -54,11 +54,11 @@ public class CustomEntityConfig extends ConfigLoader {
EntityType type = EntityType.fromId(id);
double xpMultiplier = config.getDouble(entityType + "." + entityName + ".XP_Multiplier", 1.0D);
boolean canBeTamed = config.getBoolean(entityType + "." + entityName + ".Tameable", false);
int tamingXp = config.getInt(entityType + "." + entityName + ".Tameable.Taming_XP", 0);
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + ".Tameable.CanBeSummoned", false);
int callOfTheWildId = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_ID", 0);
int callOfTheWildData = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_Data", 0);
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + ".Tameable.COTW_Material_Amount", 0);
int tamingXp = config.getInt(entityType + "." + entityName + "Taming_XP", 0);
boolean canBeSummoned = config.getBoolean(entityType + "." + entityName + "CanBeSummoned", false);
int callOfTheWildId = config.getInt(entityType + "." + entityName + "COTW_Material_ID", 0);
int callOfTheWildData = config.getInt(entityType + "." + entityName + "COTW_Material_Data", 0);
int callOfTheWildAmount = config.getInt(entityType + "." + entityName + "COTW_Material_Amount", 0);
CustomEntity entity;

View File

@@ -3,29 +3,28 @@ package com.gmail.nossr50.party;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
public class Party {
private List<String> members = new ArrayList<String>();
private List<OfflinePlayer> members = new ArrayList<OfflinePlayer>();
private String leader;
private String name;
private String password;
private boolean locked;
private ShareHandler.XpShareMode xpShareMode;
private ShareHandler.ShareMode xpShareMode = ShareHandler.ShareMode.NONE;
private ShareHandler.ShareMode itemShareMode = ShareHandler.ShareMode.NONE;
public List<String> getMembers() {
public List<OfflinePlayer> getMembers() {
return members;
}
public List<Player> getOnlineMembers() {
Player[] onlinePlayers = mcMMO.p.getServer().getOnlinePlayers();
List<Player> onlineMembers = new ArrayList<Player>();
for (Player onlinePlayer : onlinePlayers) {
if (members.contains(onlinePlayer.getName())) {
onlineMembers.add(onlinePlayer);
for (OfflinePlayer member : members) {
if (member.isOnline()) {
onlineMembers.add(member.getPlayer());
}
}
@@ -64,11 +63,19 @@ public class Party {
this.locked = locked;
}
public void setXpShareMode(ShareHandler.XpShareMode xpShareMode) {
public void setXpShareMode(ShareHandler.ShareMode xpShareMode) {
this.xpShareMode = xpShareMode;
}
public ShareHandler.XpShareMode getXpShareMode() {
public ShareHandler.ShareMode getXpShareMode() {
return xpShareMode;
}
public void setItemShareMode(ShareHandler.ShareMode itemShareMode) {
this.itemShareMode = itemShareMode;
}
public ShareHandler.ShareMode getItemShareMode() {
return itemShareMode;
}
}

View File

@@ -4,6 +4,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
@@ -21,8 +23,23 @@ public final class PartyManager {
private PartyManager() {}
public static boolean changeOrJoinParty(McMMOPlayer mcMMOPlayer, Player player, Party oldParty, String newPartyName) {
if (mcMMOPlayer.inParty()) {
if (!handlePartyChangeEvent(player, oldParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return false;
}
removeFromParty(player, oldParty);
}
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
return false;
}
return true;
}
/**
* Check if two players are in the same party.
* Check if two online players are in the same party.
*
* @param firstPlayer The first player
* @param secondPlayer The second player
@@ -68,13 +85,13 @@ public final class PartyManager {
/**
* Notify party members when a player joins
*
* @param playerName The name of the player that joins
* @param player The player that joins
* @param party The concerned party
*/
private static void informPartyMembersJoin(String playerName, Party party) {
private static void informPartyMembersJoin(OfflinePlayer player, Party party) {
for (Player member : party.getOnlineMembers()) {
if (!member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", playerName));
if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnJoin", player.getName()));
}
}
}
@@ -82,13 +99,13 @@ public final class PartyManager {
/**
* Notify party members when a party member quits.
*
* @param playerName The name of the player that quits
* @param player The player that quits
* @param party The concerned party
*/
private static void informPartyMembersQuit(String playerName, Party party) {
private static void informPartyMembersQuit(OfflinePlayer player, Party party) {
for (Player member : party.getOnlineMembers()) {
if (!member.getName().equals(playerName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", playerName));
if (!member.equals(player)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnQuit", player.getName()));
}
}
}
@@ -99,7 +116,7 @@ public final class PartyManager {
* @param player The player to check
* @return all the players in the player's party
*/
public static List<String> getAllMembers(Player player) {
public static List<OfflinePlayer> getAllMembers(Player player) {
Party party = Users.getPlayer(player).getParty();
if (party == null) {
@@ -159,10 +176,13 @@ public final class PartyManager {
*/
public static Party getPlayerParty(String playerName) {
for (Party party : parties) {
if (party.getMembers().contains(playerName)) {
return party;
for (OfflinePlayer member : party.getMembers()) {
if (member.getName().equals(playerName)) {
return party;
}
}
}
return null;
}
@@ -178,28 +198,28 @@ public final class PartyManager {
/**
* Remove a player from a party.
*
* @param playerName The name of the player to remove
* @param player The player to remove
* @param party The party
*/
public static void removeFromParty(String playerName, Party party) {
List<String> members = party.getMembers();
public static void removeFromParty(OfflinePlayer player, Party party) {
List<OfflinePlayer> members = party.getMembers();
members.remove(playerName);
members.remove(player);
if (members.isEmpty()) {
parties.remove(party);
}
else {
//If the leaving player was the party leader, appoint a new leader from the party members
if (party.getLeader().equals(playerName)) {
String newLeader = members.get(0);
party.setLeader(newLeader);
if (party.getLeader().equals(player.getName())) {
String newLeader = members.get(0).getName();
party.setLeader(newLeader);
}
informPartyMembersQuit(playerName, party);
informPartyMembersQuit(player, party);
}
McMMOPlayer mcMMOPlayer = Users.getPlayer(playerName);
McMMOPlayer mcMMOPlayer = Users.getPlayer(player.getName());
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
@@ -212,11 +232,10 @@ public final class PartyManager {
* @param party The party to remove
*/
public static void disbandParty(Party party) {
List<String> members = party.getMembers();
List<OfflinePlayer> members = party.getMembers();
for (String member : party.getMembers()) {
McMMOPlayer mcMMOPlayer = Users.getPlayer(member);
for (OfflinePlayer member : members) {
McMMOPlayer mcMMOPlayer = Users.getPlayer(member.getName());
if (mcMMOPlayer != null) {
mcMMOPlayer.removeParty();
@@ -224,9 +243,7 @@ public final class PartyManager {
}
members.clear();
if (members.isEmpty()) {
parties.remove(party);
}
parties.remove(party);
}
/**
@@ -240,21 +257,19 @@ public final class PartyManager {
public static void createParty(Player player, McMMOPlayer mcMMOPlayer, 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);
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
party.setLocked(true);//Parties are now invite-only by default, can be set to open with /party unlock
party.setLeader(player.getName());
party.setLocked(true); // Parties are now invite-only by default, can be set to open with /party unlock
if (password != null) {
party.setPassword(password);
party.setLocked(true);
player.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
}
parties.add(party);
}
else {
@@ -263,7 +278,7 @@ public final class PartyManager {
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Create", party.getName()));
addToParty(player.getName(), mcMMOPlayer, party);
addToParty(player, mcMMOPlayer, party);
}
/**
@@ -271,33 +286,16 @@ public final class PartyManager {
*
* @param player The player to add to the party
* @param mcMMOPlayer The player to add to the party
* @param partyName The party to add the player to
* @param party The party to add the player to
* @param password the password for this party, null if there was no password
*/
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, 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 (!checkPartyPassword(player, party, password)) {
public static void joinParty(Player player, McMMOPlayer mcMMOPlayer, Party party, String password) {
if (!checkPartyPassword(player, party, password)) {
return;
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Join", party.getName()));
addToParty(player.getName(), mcMMOPlayer, party);
addToParty(player, mcMMOPlayer, party);
}
/**
@@ -309,7 +307,7 @@ public final class PartyManager {
* @return true if the player can join the party
*/
public static boolean checkPartyPassword(Player player, Party party, String password) {
//Don't care about passwords if it isn't locked
// Don't care about passwords if it isn't locked
if (party.isLocked()) {
String partyPassword = party.getPassword();
@@ -347,20 +345,20 @@ public final class PartyManager {
player.sendMessage(LocaleLoader.getString("Commands.Invite.Accepted", invite.getName()));
mcMMOPlayer.removePartyInvite();
addToParty(player.getName(), mcMMOPlayer, invite);
addToParty(player, mcMMOPlayer, invite);
}
/**
* Add a player to a party
*
* @param playerName The name of the player to add to a party
* @param player The player to add to a party
* @param mcMMOPlayer The player to add to the party
* @param party The party
*/
public static void addToParty(String playerName, McMMOPlayer mcMMOPlayer, Party party) {
informPartyMembersJoin(playerName, party);
public static void addToParty(OfflinePlayer player, McMMOPlayer mcMMOPlayer, Party party) {
informPartyMembersJoin(player, party);
mcMMOPlayer.setParty(party);
party.getMembers().add(playerName);
party.getMembers().add(player);
}
/**
@@ -410,10 +408,8 @@ public final class PartyManager {
* @param mcMMOPlayer The player to check
* @return true if the player can invite
*/
public static boolean canInvite(Player player, McMMOPlayer mcMMOPlayer) {
Party party = mcMMOPlayer.getParty();
if (party == null || (party.isLocked() && !party.getLeader().equals(player.getName()))) {
public static boolean canInvite(Player player, Party party) {
if (party.isLocked() && !party.getLeader().equals(player.getName())) {
return false;
}
@@ -461,8 +457,16 @@ public final class PartyManager {
party.setLeader(partiesFile.getString(partyName + ".Leader"));
party.setPassword(partiesFile.getString(partyName + ".Password"));
party.setLocked(partiesFile.getBoolean(partyName + ".Locked"));
party.setXpShareMode(ShareHandler.XpShareMode.getFromString(partiesFile.getString(partyName + ".ExpShareMode")));
party.getMembers().addAll(partiesFile.getStringList(partyName + ".Members"));
party.setXpShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ExpShareMode")));
party.setItemShareMode(ShareHandler.ShareMode.getFromString(partiesFile.getString(partyName + ".ItemShareMode")));
List<String> memberNames = partiesFile.getStringList(partyName + ".Members");
List<OfflinePlayer> members = party.getMembers();
Server server = mcMMO.p.getServer();
for (String memberName : memberNames) {
members.add(server.getOfflinePlayer(memberName));
}
parties.add(party);
}
@@ -487,7 +491,15 @@ public final class PartyManager {
partiesFile.set(partyName + ".Password", party.getPassword());
partiesFile.set(partyName + ".Locked", party.isLocked());
partiesFile.set(partyName + ".ExpShareMode", party.getXpShareMode().toString());
partiesFile.set(partyName + ".Members", party.getMembers());
partiesFile.set(partyName + ".ItemShareMode", party.getItemShareMode().toString());
List<String> memberNames = new ArrayList<String>();
for (OfflinePlayer member : party.getMembers()) {
memberNames.add(member.getName());
}
partiesFile.set(partyName + ".Members", memberNames);
try {
partiesFile.save(new File(partiesFilePath));

View File

@@ -2,19 +2,24 @@ package com.gmail.nossr50.party;
import java.util.List;
import org.bukkit.entity.Item;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public final class ShareHandler {
public enum XpShareMode {
public enum ShareMode {
NONE,
EQUAL;
EQUAL,
RANDOM;
public static XpShareMode getFromString(String string) {
public static ShareMode getFromString(String string) {
try {
return valueOf(string);
}
@@ -69,5 +74,56 @@ public final class ShareHandler {
return false;
}
}
/**
* Distribute Items amongst party members.
*
* @param item Item that will get shared
* @param mcMMOPlayer Player who picked up the item
* @return True if the item has been shared
*/
public static boolean handleItemShare(PlayerPickupItemEvent event, McMMOPlayer mcMMOPlayer) {
Item item = event.getItem();
ItemStack itemStack = item.getItemStack();
Party party = mcMMOPlayer.getParty();
switch (party.getItemShareMode()) {
case EQUAL:
return false;
case RANDOM:
Player player = mcMMOPlayer.getPlayer();
List<Player> nearMembers = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange());
if (nearMembers.isEmpty()) {
return false;
}
int partySize = nearMembers.size() + 1;
event.setCancelled(true);
item.remove();
Player targetPlayer;
ItemStack newStack = itemStack.clone();
newStack.setAmount(1);
//TODO Improve this, if possible make this faster.
for (int i = 0; i < itemStack.getAmount(); i++) {
int randomMember = Misc.getRandom().nextInt(partySize);
if (randomMember >= nearMembers.size()) {
targetPlayer = player;
} else {
targetPlayer = nearMembers.get(randomMember);
}
targetPlayer.getInventory().addItem(newStack);
targetPlayer.updateInventory();
}
return true;
case NONE:
default:
return false;
}
}
}

View File

@@ -6,25 +6,16 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
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.Permissions;
import com.gmail.nossr50.util.Users;
public class PartyAcceptCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.accept")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (args.length) {
case 1:
player = (Player) sender;
@@ -35,17 +26,9 @@ public class PartyAcceptCommand implements CommandExecutor {
return true;
}
// Changing parties
if (mcMMOPlayer.inParty()) {
playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), mcMMOPlayer.getPartyInvite().getName(), EventReason.CHANGED_PARTIES)) {
return true;
}
PartyManager.removeFromParty(player.getName(), playerParty);
}
else if (!PartyManager.handlePartyChangeEvent(player, null, mcMMOPlayer.getPartyInvite().getName(), EventReason.JOINED_PARTY)) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), mcMMOPlayer.getPartyInvite().getName())) {
return true;
}

View File

@@ -0,0 +1,34 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
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 PartyChangeOwnerCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
Party playerParty = Users.getPlayer((Player) sender).getParty();
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
return true;
}
PartyManager.setPartyLeader(args[1], playerParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@@ -0,0 +1,50 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Users;
public class PartyChangePasswordCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party playerParty = Users.getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
unprotectParty(sender, playerParty);
return true;
case 2:
if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) {
unprotectParty(sender, playerParty);
return true;
}
protectParty(sender, playerParty, args[1]);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">"));
return true;
}
}
private void unprotectParty(CommandSender sender, Party playerParty) {
playerParty.setLocked(true);
playerParty.setPassword(null);
sender.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
}
private void protectParty(CommandSender sender, Party playerParty, String password) {
playerParty.setLocked(true);
playerParty.setPassword(password);
sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password));
}
}

View File

@@ -1,22 +1,15 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.commands.PartyChatCommand;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
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.party.ShareHandler;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class PartyCommand implements CommandExecutor {
@@ -26,6 +19,20 @@ public class PartyCommand implements CommandExecutor {
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyExpShareCommand = new PartyExpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
private CommandExecutor partyKickCommand = new PartyKickCommand();
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
private CommandExecutor partyHelpCommand = new PartyHelpCommand();
private CommandExecutor partyTeleportCommand = new PtpCommand();
private CommandExecutor partyChatCommand = new PartyChatCommand();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@@ -33,515 +40,114 @@ public class PartyCommand implements CommandExecutor {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
if (!Permissions.party(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
player = (Player) sender;
mcMMOPlayer = Users.getPlayer(player);
if (args.length < 1 || args[0].equalsIgnoreCase("info")) {
return party();
}
if (args[0].equalsIgnoreCase("join")) {
return partyJoinCommand.onCommand(sender, command, label, args);
}
else if (args[0].equalsIgnoreCase("accept")) {
return partyAcceptCommand.onCommand(sender, command, label, args);
}
else if (args[0].equalsIgnoreCase("create")) {
return partyCreateCommand.onCommand(sender, command, label, args);
}
else if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) {
return printHelp();
}
if (mcMMOPlayer.inParty()) {
if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) {
return quit();
}
else if (args[0].equalsIgnoreCase("expshare")) {
return shareExp(args);
}
else if (args[0].equalsIgnoreCase("itemshare")) {
return shareItem();
}
else if (args[0].equalsIgnoreCase("invite")) {
return invite(args);
}
else if (args[0].equalsIgnoreCase("kick")) {
return kick(args);
}
else if (args[0].equalsIgnoreCase("disband")) {
return disband();
}
else if (args[0].equalsIgnoreCase("owner")) {
return changeOwner(args);
}
else if (args[0].equalsIgnoreCase("lock")) {
return lock();
}
else if (args[0].equalsIgnoreCase("unlock")) {
return unlock();
}
else if (args[0].equalsIgnoreCase("password")) {
return changePassword(args);
}
else if (args[0].equalsIgnoreCase("rename")) {
return rename(args);
}
else {
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
}
return partyInfoCommand.onCommand(sender, command, label, args);
}
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]);
if (subcommand == null) {
return printUsage();
}
// Can't use this for lock/unlock since they're handled by the same command
if (subcommand != PartySubcommandType.LOCK && subcommand != PartySubcommandType.UNLOCK && !Permissions.partySubcommand(sender, subcommand)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (subcommand) {
case JOIN:
return partyJoinCommand.onCommand(sender, command, label, args);
case ACCEPT:
return partyAcceptCommand.onCommand(sender, command, label, args);
case CREATE:
return partyCreateCommand.onCommand(sender, command, label, args);
case HELP:
return partyHelpCommand.onCommand(sender, command, label, args);
default:
break;
}
// Party member commands
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
}
switch (subcommand) {
case INFO:
return partyInfoCommand.onCommand(sender, command, label, args);
case QUIT:
return partyQuitCommand.onCommand(sender, command, label, args);
case INVITE:
return partyInviteCommand.onCommand(sender, command, label, args);
case TELEPORT:
return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args));
case CHAT:
return partyChatCommand.onCommand(sender, command, label, extractArgs(args));
default:
break;
}
// Party leader commands
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
switch (subcommand) {
case EXPSHARE:
return partyExpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE:
return partyItemShareCommand.onCommand(sender, command, label, args);
case KICK:
return partyKickCommand.onCommand(sender, command, label, args);
case DISBAND:
return partyDisbandCommand.onCommand(sender, command, label, args);
case OWNER:
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
case LOCK:
case UNLOCK:
return partyLockCommand.onCommand(sender, command, label, args);
case PASSWORD:
return partyChangePasswordCommand.onCommand(sender, command, label, args);
case RENAME:
return partyRenameCommand.onCommand(sender, command, label, args);
default:
break;
}
return true;
}
private boolean printUsage() {
player.sendMessage(LocaleLoader.getString("Party.Help.0"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.2"));
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));
return true;
}
private boolean party() {
if (mcMMOPlayer.inParty()) {
Party party = mcMMOPlayer.getParty();
private String[] extractArgs(String[] args) {
String[] newArgs = new String[args.length - 1];
Server server = mcMMO.p.getServer();
String leader = party.getLeader();
StringBuilder tempList = new StringBuilder();
int membersNear = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()).size();
int membersOnline = party.getOnlineMembers().size() - 1;
String ItemShare = "";
String ExpShare = "";
String Split = "";
String itemShareMode = "NONE";
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.append(ChatColor.GRAY);
}
tempList.append(otherPlayerName).append(" ");
}
String status = LocaleLoader.getString("Party.Status.Locked");
if (!party.isLocked()) {
status = LocaleLoader.getString("Party.Status.Unlocked");
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), status));
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
if (xpShareEnabled) {
ExpShare = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString());
}
if (itemShareEnabled) {
ItemShare = LocaleLoader.getString("Commands.Party.ItemShare", itemShareMode);
}
if (xpShareEnabled && itemShareEnabled) {
Split = ChatColor.DARK_GRAY + " || ";
}
if (xpShareEnabled || itemShareEnabled) {
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + ExpShare + Split + ItemShare);
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", tempList));
}
else {
return printUsage();
}
return true;
}
private boolean quit() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.quit")) {
return true;
for (int i = 1; i < args.length; i++) {
newArgs[i - 1] = args[1];
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), null, EventReason.LEFT_PARTY);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
PartyManager.removeFromParty(playerName, party);
player.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
}
return false;
}
private boolean shareExp(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.expshare")) {
return true;
}
if (args.length < 2) {
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE / EQUAL]"));
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party.getLeader().equals(playerName)) {
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("false")) {
party.setXpShareMode(ShareHandler.XpShareMode.NONE);
for (Player onlineMembers : party.getOnlineMembers()) {
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.NoShare")));
}
}
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
party.setXpShareMode(ShareHandler.XpShareMode.EQUAL);
for (Player onlineMembers : party.getOnlineMembers()) {
onlineMembers.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode.Equal")));
}
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE / EQUAL]"));
return true;
}
}
return true;
}
private boolean shareItem() {
return (!CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.itemshare"));
}
private boolean printHelp() {
player.sendMessage(LocaleLoader.getString("Party.Help.3"));
player.sendMessage(LocaleLoader.getString("Party.Help.1"));
player.sendMessage(LocaleLoader.getString("Party.Help.4"));
player.sendMessage(LocaleLoader.getString("Party.Help.5"));
player.sendMessage(LocaleLoader.getString("Party.Help.6"));
player.sendMessage(LocaleLoader.getString("Party.Help.7"));
player.sendMessage(LocaleLoader.getString("Party.Help.8"));
return true;
}
private boolean invite(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.invite")) {
return true;
}
switch (args.length) {
case 2:
if (!mcMMOPlayer.inParty()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return true;
}
Player target = mcMMO.p.getServer().getPlayer(args[1]);
if (target != null) {
if (PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true;
}
if (PartyManager.canInvite(player, mcMMOPlayer)) {
Party party = mcMMOPlayer.getParty();
Users.getPlayer(target).setPartyInvite(party);
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", party.getName(), player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
default:
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
/**
* Kick a party member
*/
private boolean kick(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.kick")) {
return true;
}
switch (args.length) {
case 2:
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
return true;
}
Player target = mcMMO.p.getServer().getOfflinePlayer(args[1]).getPlayer();
if (target != null) {
String partyName = party.getName();
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(args[1], party);
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
return true;
default:
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
/**
* Disband the current party, kicks out all party members.
*/
private boolean disband() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.disband")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party.getLeader().equals(playerName)) {
for (Player onlineMembers : party.getOnlineMembers()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(party);
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
return true;
}
/**
* Change the owner of the current party
*/
private boolean changeOwner(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.owner")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (args.length < 2) {
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
return true;
}
if (party.getLeader().equals(playerName)) {
if (!party.getMembers().contains(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
return true;
}
PartyManager.setPartyLeader(args[1], party);
}
return true;
}
/**
* Lock the current party
*/
private boolean lock() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.lock")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party == null) {
player.sendMessage("Commands.Party.None");
return true;
}
if (!party.getLeader().equals(playerName)) {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
if (party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsLocked"));
}
else {
party.setLocked(true);
player.sendMessage(LocaleLoader.getString("Party.Locked"));
}
return true;
}
/**
* Unlock the current party
*/
private boolean unlock() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.unlock")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (party == null) {
player.sendMessage("Commands.Party.None");
return true;
}
if (!party.getLeader().equals(playerName)) {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
if (!party.isLocked()) {
player.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
}
else {
party.setLocked(false);
player.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
return true;
}
private boolean changePassword(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.password")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
if (!party.getLeader().equals(playerName)) {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
if (args.length < 2) {
party.setLocked(true);
party.setPassword(null);
player.sendMessage(LocaleLoader.getString("Party.Password.Removed"));
return true;
}
party.setLocked(true);
party.setPassword(args[1]);
player.sendMessage(LocaleLoader.getString("Party.Password.Set", args[1]));
return true;
}
/**
* Rename the current party
*/
private boolean rename(String[] args) {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.rename")) {
return true;
}
String playerName = player.getName();
Party party = mcMMOPlayer.getParty();
String leader = party.getLeader();
if (party.getLeader().equals(playerName)) {
if (args.length < 2) {
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
return true;
}
String newPartyName = args[1];
// This is to prevent party leaders from spamming other players with the rename message
if (!party.getName().equals(newPartyName)) {
Party newParty = PartyManager.getParty(newPartyName);
// Check to see if the party exists, and if it does cancel renaming the party
if (newParty != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName));
return true;
}
for (Player onlineMembers : party.getOnlineMembers()) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), newPartyName, EventReason.CHANGED_PARTIES);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
if (!onlineMembers.getName().equals(leader)) {
onlineMembers.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leader, newPartyName));
}
}
party.setName(newPartyName);
}
player.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
}
return true;
return newArgs;
}
}

View File

@@ -6,25 +6,17 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.McMMOPlayer;
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.Permissions;
import com.gmail.nossr50.util.Users;
public class PartyCreateCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.create")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (args.length) {
case 2:
case 3:
@@ -32,7 +24,7 @@ public class PartyCreateCommand implements CommandExecutor {
// Check to see if the party exists, and if it does cancel creating a new party
if (newParty != null) {
player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1]));
sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", args[1]));
return true;
}
@@ -40,15 +32,7 @@ public class PartyCreateCommand implements CommandExecutor {
mcMMOPlayer = Users.getPlayer(player);
// Changing parties
if (mcMMOPlayer.inParty()) {
playerParty = mcMMOPlayer.getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), args[1], EventReason.CHANGED_PARTIES)) {
return true;
}
PartyManager.removeFromParty(player.getName(), playerParty);
}
else if (!PartyManager.handlePartyChangeEvent(player, null, args[1], EventReason.JOINED_PARTY)) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, mcMMOPlayer.getParty(), args[1])) {
return true;
}

View File

@@ -0,0 +1,37 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.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 PartyDisbandCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
Party playerParty = Users.getPlayer((Player) sender).getParty();
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
member.sendMessage(LocaleLoader.getString("Party.Disband"));
}
PartyManager.disbandParty(playerParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
return true;
}
}
}

View File

@@ -0,0 +1,55 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class PartyExpShareCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getExpShareEnabled()) {
sender.sendMessage(LocaleLoader.getString("Party.ExpShare.Disabled"));
return true;
}
switch (args.length) {
case 2:
playerParty = Users.getPlayer((Player) sender).getParty();
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
handleChangingShareMode(ShareMode.NONE);
}
else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even") || args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
handleChangingShareMode(ShareMode.EQUAL);
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "[NONE | EQUAL]"));
}
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "expshare", "<NONE | EQUAL>"));
return true;
}
}
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
playerParty.setXpShareMode(mode);
for (Player member : playerParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Exp"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
}
}
}

View File

@@ -0,0 +1,30 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.locale.LocaleLoader;
public class PartyHelpCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit"));
sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party <lock|unlock>"));
sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner"));
sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help"));
return true;
}
}
}

View File

@@ -0,0 +1,97 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.McMMOPlayer;
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 PartyInfoCommand implements CommandExecutor {
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
player = (Player) sender;
McMMOPlayer mcMMOPlayer = Users.getPlayer(player);
playerParty = mcMMOPlayer.getParty();
displayPartyHeader();
displayShareModeInfo();
displayMemberInfo();
return true;
}
private String createMembersList() {
StringBuilder memberList = new StringBuilder();
for (OfflinePlayer member : playerParty.getMembers()) {
if (playerParty.getLeader().equals(member.getName())) {
memberList.append(ChatColor.GOLD).append(member.getName()).append(" ");
}
else if (member.isOnline()) {
memberList.append(ChatColor.WHITE).append(member.getName()).append(" ");
}
else {
memberList.append(ChatColor.GRAY).append(member.getName()).append(" ");
}
}
return memberList.toString();
}
private void displayShareModeInfo() {
boolean xpShareEnabled = Config.getInstance().getExpShareEnabled();
boolean itemShareEnabled = Config.getInstance().getItemShareEnabled();
if (!xpShareEnabled && !itemShareEnabled) {
return;
}
String expShareInfo = "";
String itemShareInfo = "";
String separator = "";
if (xpShareEnabled) {
expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString());
}
if (itemShareEnabled) {
itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString());
}
if (xpShareEnabled && itemShareEnabled) {
separator = ChatColor.DARK_GRAY + " || ";
}
player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo);
}
private void displayPartyHeader() {
player.sendMessage(LocaleLoader.getString("Commands.Party.Header"));
if (playerParty.isLocked()) {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked")));
}
else {
player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked")));
}
}
private void displayMemberInfo() {
int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size();
int membersOnline = playerParty.getOnlineMembers().size() - 1;
player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header"));
player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline));
player.sendMessage(LocaleLoader.getString("Commands.Party.Members", createMembersList()));
}
}

View File

@@ -0,0 +1,71 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.McMMOPlayer;
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 PartyInviteCommand implements CommandExecutor {
private McMMOPlayer mcMMOTarget;
private Player target;
private McMMOPlayer mcMMOPlayer;
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) {
sender.sendMessage(LocaleLoader.getString("Party.NotOnline", args[1]));
return true;
}
mcMMOTarget = Users.getPlayer(args[1]);
if (mcMMOTarget == null) {
sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
}
target = mcMMOTarget.getPlayer();
mcMMOPlayer = Users.getPlayer((Player) sender);
player = mcMMOPlayer.getPlayer();
if (player.equals(target)) {
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true;
}
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true;
}
playerParty = mcMMOPlayer.getParty();
if (!PartyManager.canInvite(player, playerParty)) {
player.sendMessage(LocaleLoader.getString("Party.Locked"));
return true;
}
mcMMOTarget.setPartyInvite(playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.0", playerParty.getName(), player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.Party.Invite.1"));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "invite", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@@ -0,0 +1,60 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.party.ShareHandler.ShareMode;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public class PartyItemShareCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Config.getInstance().getItemShareEnabled()) {
sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled"));
return true;
}
switch (args.length) {
case 2:
playerParty = Users.getPlayer((Player) sender).getParty();
if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
handleChangingShareMode(ShareMode.NONE);
}
// else if (args[1].equalsIgnoreCase("equal") || args[1].equalsIgnoreCase("even")) {
// handleChangingShareMode(ShareMode.EQUAL);
// }
else if (args[1].equalsIgnoreCase("random")) {
handleChangingShareMode(ShareMode.RANDOM);
}
else {
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
}
return true;
default:
// sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | EQUAL | RANDOM>"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "itemshare", "<NONE | RANDOM>"));
return true;
}
}
private void handleChangingShareMode(ShareHandler.ShareMode mode) {
playerParty.setItemShareMode(mode);
for (Player member : playerParty.getOnlineMembers()) {
member.sendMessage(LocaleLoader.getString("Commands.Party.SetSharing", LocaleLoader.getString("Party.ShareType.Item"), LocaleLoader.getString("Party.ShareMode." + StringUtils.getCapitalized(mode.toString()))));
}
}
}

View File

@@ -5,13 +5,11 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.PlayerProfile;
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.Permissions;
import com.gmail.nossr50.util.Users;
public class PartyJoinCommand implements CommandExecutor {
@@ -25,11 +23,6 @@ public class PartyJoinCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.join")) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
switch (args.length) {
case 2:
case 3:
@@ -46,18 +39,11 @@ public class PartyJoinCommand implements CommandExecutor {
}
// Changing parties
if (mcMMOPlayer.inParty()) {
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), targetParty.getName(), EventReason.CHANGED_PARTIES)) {
return true;
}
PartyManager.removeFromParty(player.getName(), playerParty);
}
else if (!PartyManager.handlePartyChangeEvent(player, null, targetParty.getName(), EventReason.JOINED_PARTY)) {
if (!PartyManager.changeOrJoinParty(mcMMOPlayer, player, playerParty, targetParty.getName())) {
return true;
}
PartyManager.joinParty(player, mcMMOPlayer, targetParty.getName(), password);
PartyManager.joinParty(player, mcMMOPlayer, targetParty, password);
return true;
default:
@@ -75,24 +61,20 @@ public class PartyJoinCommand implements CommandExecutor {
}
private boolean canJoinParty(CommandSender sender, String targetName) {
mcMMOTarget = Users.getPlayer(targetName);
if (mcMMOTarget == null) {
PlayerProfile playerProfile = new PlayerProfile(targetName, false);
if (!playerProfile.isLoaded()) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
return false;
}
}
target = mcMMOTarget.getPlayer();
if (!target.isOnline()) {
if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) {
sender.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName));
return false;
}
mcMMOTarget = Users.getPlayer(targetName);
if (mcMMOTarget == null) {
sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return false;
}
target = mcMMOTarget.getPlayer();
if (!mcMMOTarget.inParty()) {
sender.sendMessage(LocaleLoader.getString("Party.PlayerNotInParty", targetName));
return false;

View File

@@ -0,0 +1,49 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.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 PartyKickCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 2:
Party playerParty = Users.getPlayer((Player) sender).getParty();
OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);
if (!playerParty.getMembers().contains(target)) {
sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
return true;
}
if (target.isOnline()) {
Player onlineTarget = target.getPlayer();
String partyName = playerParty.getName();
if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
return true;
}
onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
}
PartyManager.removeFromParty(target, playerParty);
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
return true;
}
}
}

View File

@@ -0,0 +1,97 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class PartyLockCommand implements CommandExecutor {
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
playerParty = Users.getPlayer((Player) sender).getParty();
switch (args.length) {
case 1:
if (args[0].equalsIgnoreCase("lock")) {
lockParty(sender, command);
}
else if (args[0].equalsIgnoreCase("unlock")) {
unlockParty(sender, command);
}
return true;
case 2:
if (!args[0].equalsIgnoreCase("lock")) {
sendUsageStrings(sender);
return true;
}
if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) {
lockParty(sender, command);
}
else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) {
unlockParty(sender, command);
}
else {
sendUsageStrings(sender);
}
return true;
default:
sendUsageStrings(sender);
return true;
}
}
/**
* Handle locking a party.
*/
private void lockParty(CommandSender sender, Command command) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.LOCK)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsLocked"));
return;
}
playerParty.setLocked(true);
sender.sendMessage(LocaleLoader.getString("Party.Locked"));
}
/**
* Handle unlocking a party.
*
* @return true if party is successfully unlocked, false otherwise.
*/
private void unlockParty(CommandSender sender, Command command) {
if (!Permissions.partySubcommand(sender, PartySubcommandType.UNLOCK)) {
sender.sendMessage(command.getPermissionMessage());
return;
}
if (!playerParty.isLocked()) {
sender.sendMessage(LocaleLoader.getString("Party.IsntLocked"));
return;
}
playerParty.setLocked(false);
sender.sendMessage(LocaleLoader.getString("Party.Unlocked"));
}
private void sendUsageStrings(CommandSender sender) {
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]"));
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock"));
}
}

View File

@@ -0,0 +1,38 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.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 PartyQuitCommand implements CommandExecutor {
private Player player;
private Party playerParty;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 1:
player = (Player) sender;
playerParty = Users.getPlayer(player).getParty();
if (!PartyManager.handlePartyChangeEvent(player, playerParty.getName(), null, EventReason.LEFT_PARTY)) {
return true;
}
PartyManager.removeFromParty(player, playerParty);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Leave"));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "[quit|q|leave]"));
return true;
}
}
}

View File

@@ -0,0 +1,59 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.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 PartyRenameCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Party playerParty = Users.getPlayer((Player) sender).getParty();
String leaderName = playerParty.getLeader();
switch (args.length) {
case 2:
String newPartyName = args[1];
// This is to prevent party leaders from spamming other players with the rename message
if (playerParty.getName().equalsIgnoreCase(newPartyName)) {
sender.sendMessage(LocaleLoader.getString("Party.Rename.Same"));
return true;
}
Party newParty = PartyManager.getParty(newPartyName);
// Check to see if the party exists, and if it does cancel renaming the party
if (newParty != null) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName));
return true;
}
for (Player member : playerParty.getOnlineMembers()) {
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) {
return true;
}
if (!member.getName().equals(leaderName)) {
member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName));
}
}
playerParty.setName(newPartyName);
sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName));
return true;
default:
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">"));
return true;
}
}
}

View File

@@ -0,0 +1,45 @@
package com.gmail.nossr50.party.commands;
public enum PartySubcommandType {
JOIN,
ACCEPT,
CREATE,
HELP,
INFO,
QUIT,
EXPSHARE,
ITEMSHARE,
INVITE,
KICK,
DISBAND,
OWNER,
LOCK,
UNLOCK,
PASSWORD,
RENAME,
TELEPORT,
CHAT;
public static PartySubcommandType getSubcommand(String commandName) {
for (PartySubcommandType command : values()) {
if (command.name().equalsIgnoreCase(commandName)) {
return command;
}
}
if (commandName.equalsIgnoreCase("?")) {
return HELP;
}
else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) {
return QUIT;
}
else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) {
return EXPSHARE;
}
else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) {
return ITEMSHARE;
}
return null;
}
}

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.party.commands;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@@ -18,36 +19,40 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class PtpCommand implements CommandExecutor {
private final mcMMO plugin;
private Player player;
private McMMOPlayer mcMMOPlayer;
private PlayerProfile playerProfile;
public PtpCommand(mcMMO instance) {
this.plugin = instance;
}
private Player target;
private McMMOPlayer mcMMOTarget;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
String usage = LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">");
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
return true;
}
switch (args.length) {
case 1:
player = (Player) sender;
mcMMOPlayer = Users.getPlayer(player);
PlayerProfile playerProfile = mcMMOPlayer.getProfile();
playerProfile = mcMMOPlayer.getProfile();
if (args[0].equalsIgnoreCase("toggle")) {
if (!Permissions.partyTeleportToggle(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
return togglePartyTeleportation();
}
else if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) {
if (!Permissions.partyTeleportAcceptAll(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
return acceptAnyTeleportRequest();
}
@@ -59,68 +64,37 @@ public class PtpCommand implements CommandExecutor {
}
if (args[0].equalsIgnoreCase("accept")) {
if (!Permissions.partyTeleportAccept(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
return acceptTeleportRequest();
}
return sendTeleportRequest(args[0]);
default:
sender.sendMessage(usage);
return true;
return false;
}
}
private boolean sendTeleportRequest(String args) {
Player target = plugin.getServer().getPlayer(args);
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
private boolean sendTeleportRequest(String targetName) {
if (!canTeleport(targetName)) {
return true;
}
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return true;
if (!mcMMOTarget.getPtpConfirmRequired()) {
return handlePartyTeleportEvent(player, target);
}
if (target.isDead()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return true;
}
mcMMOTarget.setPtpRequest(player);
mcMMOTarget.actualizePtpTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
if (PartyManager.inSameParty(player, target)) {
McMMOPlayer targetMcMMOPlayer = Users.getPlayer(target);
if (!targetMcMMOPlayer.getPtpEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName()));
return true;
}
if (!targetMcMMOPlayer.getPtpConfirmRequired()) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
player.teleport(target);
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName()));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName()));
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
} else {
targetMcMMOPlayer.setPtpRequest(player);
targetMcMMOPlayer.actualizePtpTimeout();
player.sendMessage(LocaleLoader.getString("Commands.Invite.Success"));
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire));
}
}
else {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
}
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName()));
target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire));
return true;
}
@@ -130,10 +104,6 @@ public class PtpCommand implements CommandExecutor {
return true;
}
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.accept")) {
return true;
}
int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout();
if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) {
@@ -142,50 +112,33 @@ public class PtpCommand implements CommandExecutor {
return true;
}
Player target = mcMMOPlayer.getPtpRequest();
target = mcMMOPlayer.getPtpRequest();
if (target == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
if (!canTeleport(target.getName())) {
mcMMOPlayer.removePtpRequest();
return true;
}
if (target.isDead()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return true;
}
if (Config.getInstance().getPTPCommandWorldPermissions()) {
World targetWorld = target.getWorld();
World playerWorld = player.getWorld();
if(Config.getInstance().getPTPCommandWorldPermissions()) {
String perm = "mcmmo.commands.ptp.world.";
if(!Permissions.hasDynamicPermission(target, perm + "all", "op")) {
if(!Permissions.hasDynamicPermission(target, perm + target.getWorld().getName(), "op")) {
if (!Permissions.partyTeleportAllWorlds(target)) {
if (!Permissions.partyTeleportWorld(target, targetWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", targetWorld.getName()));
return true;
}
else if(target.getWorld() != player.getWorld() && !Permissions.hasDynamicPermission(target, perm + player.getWorld().getName(), "op")) {
else if (targetWorld != playerWorld && !Permissions.partyTeleportWorld(target, playerWorld)) {
target.sendMessage(LocaleLoader.getString("Commands.ptp.NoWorldPermissions", playerWorld.getName()));
return true;
}
}
}
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(target, player, mcMMOPlayer.getParty().getName());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
target.teleport(player);
target.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName()));
player.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName()));
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
return true;
return handlePartyTeleportEvent(target, player);
}
private boolean acceptAnyTeleportRequest() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.acceptall")) {
return true;
}
if (mcMMOPlayer.getPtpConfirmRequired()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled"));
}
@@ -198,10 +151,6 @@ public class PtpCommand implements CommandExecutor {
}
private boolean togglePartyTeleportation() {
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.toggle")) {
return true;
}
if (mcMMOPlayer.getPtpEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled"));
}
@@ -212,4 +161,59 @@ public class PtpCommand implements CommandExecutor {
mcMMOPlayer.togglePtpUse();
return true;
}
private boolean canTeleport(String targetName) {
if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) {
player.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName));
return false;
}
mcMMOTarget = Users.getPlayer(targetName);
if (mcMMOTarget == null) {
player.sendMessage(LocaleLoader.getString("Party.Player.Invalid"));
return false;
}
target = mcMMOTarget.getPlayer();
if (player.equals(target)) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Self"));
return false;
}
if (!PartyManager.inSameParty(player, target)) {
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName));
return false;
}
if (!mcMMOTarget.getPtpEnabled()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName()));
return false;
}
if (target.isDead()) {
player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead"));
return false;
}
return true;
}
private boolean handlePartyTeleportEvent(Player player, Player target) {
McMMOPlayer mcMMOPlayer= Users.getPlayer(player);
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName());
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
player.teleport(target);
player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", target.getName()));
target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", player.getName()));
mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis());
return true;
}
}

View File

@@ -0,0 +1,10 @@
package com.gmail.nossr50.party.runnables;
import com.gmail.nossr50.party.PartyManager;
public class PartiesLoader implements Runnable {
@Override
public void run() {
PartyManager.loadParties();
}
}

View File

@@ -1,14 +1,14 @@
package com.gmail.nossr50.skills.runnables;
package com.gmail.nossr50.party.runnables;
import java.util.ArrayList;
import java.util.Iterator;
import org.bukkit.OfflinePlayer;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.party.Party;
import com.gmail.nossr50.party.PartyManager;
public class PartyAutoKick implements Runnable {
@Override
public void run() {
updatePartyMembers();
@@ -18,14 +18,13 @@ public class PartyAutoKick implements Runnable {
long currentTime = System.currentTimeMillis();
long kickTime = 24L * 60L * 60L * 1000L * Config.getInstance().getAutoPartyKickTime();
ArrayList<Party> parties = new ArrayList<Party>(PartyManager.getParties());
for (Iterator<Party> partyIterator = PartyManager.getParties().iterator(); partyIterator.hasNext();) {
Party party = partyIterator.next();
for (Party party : parties) {
ArrayList<String> members = new ArrayList<String>(party.getMembers());
for (String member : members) {
long lastPlayed = mcMMO.p.getServer().getOfflinePlayer(member).getLastPlayed();
for (Iterator<OfflinePlayer> memberIterator = party.getMembers().iterator(); memberIterator.hasNext();) {
OfflinePlayer member = memberIterator.next();
if (currentTime - lastPlayed > kickTime) {
if (currentTime - member.getLastPlayed() > kickTime) {
PartyManager.removeFromParty(member, party);
}
}

View File

@@ -36,10 +36,10 @@ public class McRankAsync implements Runnable {
}
if (skills.get(skillType.name()) == null) {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), LocaleLoader.getString("Commands.mcrank.Unranked")));
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.localizeSkillName(skillType), skills.get(skillType.name())));
sender.sendMessage(LocaleLoader.getString("Commands.mcrank.Skill", SkillTools.getSkillName(skillType), skills.get(skillType.name())));
}
}

View File

@@ -0,0 +1,68 @@
package com.gmail.nossr50.runnables;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.Database;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
public class McTopAsync implements Runnable {
private CommandSender sender;
private String query;
private int page;
private Command command;
public McTopAsync(int page, String query, CommandSender sender, Command command) {
this.page = page;
this.query = query;
this.sender = sender;
this.command = command;
}
@Override
public void run() {
if (!query.equalsIgnoreCase("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
if (!Permissions.mctop(sender, SkillType.getSkill(query))) {
sender.sendMessage(command.getPermissionMessage());
return;
}
}
String tablePrefix = Config.getInstance().getMySQLTablePrefix();
final HashMap<Integer, ArrayList<String>> userslist = Database.read("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 ORDER BY " + query + " DESC, user LIMIT " + ((page * 10) - 10) + ",10");
Bukkit.getScheduler().scheduleSyncDelayedTask(mcMMO.p, new Runnable() {
@Override
public void run() {
if (query.equals("taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing")) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
} else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", StringUtils.getCapitalized(query)));
}
int place = (page * 10) - 9;
for (int i = 1; i <= 10; i++) {
if (userslist.get(i) == null) {
break;
}
// Format: 1. Playername - skill value
sender.sendMessage(place + ". " + ChatColor.GREEN + userslist.get(i).get(1) + " - " + ChatColor.WHITE + userslist.get(i).get(0));
place++;
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
}, 1L);
}
}

View File

@@ -1,38 +0,0 @@
package com.gmail.nossr50.runnables;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitScheduler;
import com.gmail.nossr50.mcMMO;
public class MobStoreCleaner implements Runnable {
private int taskID;
public MobStoreCleaner() {
taskID = -1;
start();
}
public void start() {
if (taskID >= 0) {
return;
}
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
taskID = scheduler.scheduleSyncRepeatingTask(mcMMO.p, this, 12000, 12000);
}
public void stop() {
if (taskID < 0) {
return;
}
Bukkit.getServer().getScheduler().cancelTask(taskID);
taskID = -1;
}
@Override
public void run() {
mcMMO.placeStore.cleanMobLists();
}
}

View File

@@ -10,14 +10,15 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.Users;
public abstract class SkillCommand implements CommandExecutor {
private SkillType skill;
protected SkillType skill;
private String skillString;
protected Player player;
@@ -31,7 +32,7 @@ public abstract class SkillCommand implements CommandExecutor {
public SkillCommand(SkillType skill) {
this.skill = skill;
this.skillString = Misc.getCapitalized(skill.toString());
this.skillString = StringUtils.getCapitalized(skill.toString());
}
@Override
@@ -49,8 +50,8 @@ public abstract class SkillCommand implements CommandExecutor {
}
skillValue = profile.getSkillLevel(skill);
isLucky = Permissions.lucky(player, skill);
hasEndurance = (Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player));
isLucky = Permissions.lucky(sender, skill);
hasEndurance = (Permissions.twelveSecondActivationBoost(sender) || Permissions.eightSecondActivationBoost(sender) || Permissions.fourSecondActivationBoost(sender));
dataCalculations();
permissionsCheck();
@@ -124,27 +125,13 @@ public abstract class SkillCommand implements CommandExecutor {
protected String[] calculateLengthDisplayValues() {
int maxLength = skill.getAbility().getMaxTicks();
int length = 2 + (int) (skillValue / Misc.abilityLengthIncreaseLevel);
int enduranceLength = 0;
if (Permissions.activationTwelve(player)) {
enduranceLength = length + 12;
}
else if (Permissions.activationEight(player)) {
enduranceLength = length + 8;
}
else if (Permissions.activationFour(player)) {
enduranceLength = length + 4;
}
int length = 2 + (int) (skillValue / SkillTools.abilityLengthIncreaseLevel);
int enduranceLength = PerksUtils.handleActivationPerks(player, length, maxLength);
if (maxLength != 0) {
if (length > maxLength) {
length = maxLength;
}
if (enduranceLength > maxLength) {
enduranceLength = maxLength;
}
}
return new String[] { String.valueOf(length), String.valueOf(enduranceLength) };
@@ -153,7 +140,7 @@ public abstract class SkillCommand implements CommandExecutor {
protected void luckyEffectsDisplay() {
if (isLucky) {
String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix");
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillTools.localizeSkillName(skill))));
player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", SkillTools.getSkillName(skill))));
}
}

View File

@@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.StringUtils;
public final class SkillGuide {
private SkillGuide() {}
@@ -50,15 +50,13 @@ public final class SkillGuide {
}
public static void clearChat(Player player) {
for (int x = 0; x < 20; x++) {
player.sendMessage("");
}
player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}
public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) {
String skillName = skilltype.toString();
String capitalized = Misc.getCapitalized(skillName);
String localized = SkillTools.localizeSkillName(skilltype);
String capitalized = StringUtils.getCapitalized(skillName);
String localized = SkillTools.getSkillName(skilltype);
player.sendMessage(LocaleLoader.getString("Guides.Available", localized, localized.toLowerCase()));
String address = "Guides." + capitalized;
@@ -84,19 +82,19 @@ public final class SkillGuide {
case 2:
int totalPages = SkillGuide.getTotalPageNumber(address);
if (!Misc.isInt(args[1])) {
if (!StringUtils.isInt(args[1])) {
player.sendMessage(LocaleLoader.getString("Guides.Page.Invalid"));
return true;
}
if (Misc.getInt(args[1]) > totalPages) {
if (Integer.parseInt(args[1]) > totalPages) {
player.sendMessage(LocaleLoader.getString("Guides.Page.OutOfRange", totalPages));
return true;
}
SkillGuide.clearChat(player);
for (String target : SkillGuide.grabPageContents(localized, address, Misc.getInt(args[1]))) {
for (String target : SkillGuide.grabPageContents(localized, address, Integer.parseInt(args[1]))) {
player.sendMessage(target);
}

View File

@@ -1,19 +1,20 @@
package com.gmail.nossr50.skills;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public abstract class SkillManager {
protected McMMOPlayer mcMMOPlayer;
protected int skillLevel;
protected int activationChance;
protected SkillType skill;
public SkillManager(McMMOPlayer mcMMOPlayer, SkillType skill) {
this.mcMMOPlayer = mcMMOPlayer;
this.skillLevel = mcMMOPlayer.getProfile().getSkillLevel(skill);
this.activationChance = Misc.calculateActivationChance(Permissions.lucky(mcMMOPlayer.getPlayer(), skill));
this.activationChance = PerksUtils.handleLuckyPerks(mcMMOPlayer.getPlayer(), skill);
this.skill = skill;
}
public McMMOPlayer getMcMMOPlayer() {
@@ -27,4 +28,8 @@ public abstract class SkillManager {
public int getActivationChance() {
return activationChance;
}
public SkillType getSkill() {
return skill;
}
}

View File

@@ -17,9 +17,6 @@ public class Acrobatics {
public static int rollXpModifier = AdvancedConfig.getInstance().getRollXPModifier();
public static int fallXpModifier = AdvancedConfig.getInstance().getFallXPModifier();
public static boolean pvpEnabled = Config.getInstance().getAcrobaticsPVP();
public static boolean pveEnabled = Config.getInstance().getAcrobaticsPVE();
public static boolean afkLevelingDisabled = Config.getInstance().getAcrobaticsAFKDisabled();
public static boolean dodgeLightningDisabled = Config.getInstance().getDodgeLightningDisabled();
}
}

View File

@@ -53,7 +53,7 @@ public abstract class AcrobaticsEventHandler {
protected boolean isFatal(int damage) {
Player player = manager.getMcMMOPlayer().getPlayer();
if (Misc.isNPCPlayer(player) || player.getHealth() - damage < 1) {
if (Misc.isNPCEntity(player) || player.getHealth() - damage < 1) {
return true;
}

View File

@@ -1,11 +1,14 @@
package com.gmail.nossr50.skills.acrobatics;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ParticleEffectUtils;
public class DodgeEventHandler extends AcrobaticsEventHandler {
protected DodgeEventHandler(AcrobaticsManager manager, EntityDamageEvent event) {
@@ -17,7 +20,7 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
@Override
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Acrobatics.dodgeMaxBonusLevel);
}
@Override
@@ -38,7 +41,14 @@ public class DodgeEventHandler extends AcrobaticsEventHandler {
@Override
protected void sendAbilityMessage() {
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
Player dodgingPlayer = mcMMOPlayer.getPlayer();
ParticleEffectUtils.playDodgeEffect(dodgingPlayer);
if (mcMMOPlayer.getProfile().useChatNotifications()) {
dodgingPlayer.sendMessage(LocaleLoader.getString("Acrobatics.Combat.Proc"));
}
}
@Override

View File

@@ -4,8 +4,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class RollEventHandler extends AcrobaticsEventHandler {
@@ -29,7 +29,7 @@ public class RollEventHandler extends AcrobaticsEventHandler {
skillModifer = skillModifer * 2;
}
skillModifer = Misc.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel);
skillModifer = SkillTools.skillCheck(skillModifer, Acrobatics.rollMaxBonusLevel);
this.skillModifier = skillModifer;
}

View File

@@ -9,7 +9,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Misc;
public class Archery {
@@ -26,9 +25,6 @@ public class Archery {
public static double dazeMaxBonus = AdvancedConfig.getInstance().getDazeBonusMax();
public static int dazeModifier = AdvancedConfig.getInstance().getDazeModifier();
public static boolean pvpEnabled = Config.getInstance().getArcheryPVP();
public static boolean pveEnabled = Config.getInstance().getArcheryPVE();
public static double distanceXpModifer = 0.025;
protected static void incrementTrackerValue(LivingEntity livingEntity) {

View File

@@ -45,9 +45,9 @@ public class ArcheryCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canSkillShot = Permissions.archeryBonus(player);
canSkillShot = Permissions.bonusDamage(player, skill);
canDaze = Permissions.daze(player);
canRetrieve = Permissions.trackArrows(player);
canRetrieve = Permissions.arrowRetrieval(player);
}
@Override

View File

@@ -75,7 +75,7 @@ public class ArcheryManager extends SkillManager {
* @param event The event to modify.
*/
public void skillShot(EntityDamageEvent event) {
if (skillLevel >= Archery.skillShotIncreaseLevel && Permissions.archeryBonus(mcMMOPlayer.getPlayer())) {
if (skillLevel >= Archery.skillShotIncreaseLevel && Permissions.bonusDamage(mcMMOPlayer.getPlayer(), skill)) {
SkillShotEventHandler eventHandler = new SkillShotEventHandler(this, event);
eventHandler.calculateDamageBonus();

View File

@@ -2,7 +2,7 @@ package com.gmail.nossr50.skills.archery;
import org.bukkit.entity.LivingEntity;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
public class ArrowTrackingEventHandler {
private ArcheryManager manager;
@@ -18,7 +18,7 @@ public class ArrowTrackingEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.retrieveMaxBonusLevel);
}
protected void addToTracker() {

View File

@@ -3,21 +3,26 @@ package com.gmail.nossr50.skills.archery;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Users;
public class DazeEventHandler {
private ArcheryManager manager;
private McMMOPlayer mcMMOPlayer;
private EntityDamageEvent event;
private Player defender;
private final static int DAZE_CHANCE = 50;
protected int skillModifier;
protected DazeEventHandler (ArcheryManager manager, EntityDamageEvent event, Player defender) {
this.manager = manager;
this.mcMMOPlayer = manager.getMcMMOPlayer();
this.event = event;
this.defender = defender;
@@ -25,25 +30,26 @@ public class DazeEventHandler {
}
protected void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Archery.dazeMaxBonusLevel);
}
protected void handleDazeEffect() {
Location location = defender.getLocation();
if (Misc.getRandom().nextInt(100) > DAZE_CHANCE) {
location.setPitch(90);
}
else {
location.setPitch(-90);
}
location.setPitch(90 - Misc.getRandom().nextInt(181));
defender.teleport(location);
defender.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 20 * 10, 10));
event.setDamage(event.getDamage() + Archery.dazeModifier);
}
protected void sendAbilityMessages() {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
if (Users.getPlayer(defender).getProfile().useChatNotifications()) {
defender.sendMessage(LocaleLoader.getString("Combat.TouchedFuzzy"));
}
if (mcMMOPlayer.getProfile().useChatNotifications()) {
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed"));
}
}
}

View File

@@ -28,4 +28,4 @@ public class AxeBonusDamageEventHandler {
event.setDamage(damage + damageBonus);
}
}
}

View File

@@ -49,10 +49,7 @@ public class AxeManager extends SkillManager {
public void impact(EntityDamageByEntityEvent event, LivingEntity target) {
ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target);
if (Misc.hasArmor(target)) {
eventHandler.damageArmor();
}
else {
if (!eventHandler.applyImpact()) {
eventHandler.applyGreaterImpact();
}
}

View File

@@ -1,7 +1,6 @@
package com.gmail.nossr50.skills.axes;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
public class Axes {
public static int bonusDamageMaxBonus = AdvancedConfig.getInstance().getBonusDamageAxesBonusMax();
@@ -20,7 +19,4 @@ public class Axes {
public static int greaterImpactBonusDamage = AdvancedConfig.getInstance().getGreaterImpactBonusDamage();
public static int skullSplitterModifier = AdvancedConfig.getInstance().getSkullSplitterModifier();
public static boolean pvpEnabled = Config.getInstance().getAxesPVP();
public static boolean pveEnabled = Config.getInstance().getAxesPVE();
}

View File

@@ -52,9 +52,9 @@ public class AxesCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canSkullSplitter = Permissions.skullSplitter(player);
canCritical = Permissions.criticalHit(player);
canBonusDamage = Permissions.axeBonus(player);
canImpact = Permissions.impact(player);
canCritical = Permissions.criticalStrikes(player);
canBonusDamage = Permissions.bonusDamage(player, skill);
canImpact = Permissions.armorImpact(player);
canGreaterImpact = Permissions.greaterImpact(player);
}

View File

@@ -1,11 +1,14 @@
package com.gmail.nossr50.skills.axes;
import org.bukkit.Effect;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.util.Users;
public class CriticalHitEventHandler {
private AxeManager manager;
@@ -34,14 +37,25 @@ public class CriticalHitEventHandler {
}
protected void sendAbilityMessages() {
manager.getMcMMOPlayer().getPlayer().sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
McMMOPlayer mcMMOPlayer = manager.getMcMMOPlayer();
Player attacker = mcMMOPlayer.getPlayer();
attacker.playEffect(defender.getEyeLocation(), Effect.MOBSPAWNER_FLAMES, 0);
if (mcMMOPlayer.getProfile().useChatNotifications()) {
attacker.sendMessage(LocaleLoader.getString("Axes.Combat.CriticalHit"));
}
if (defender instanceof Player) {
((Player) defender).sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
Player defendingPlayer = (Player) defender;
if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) {
defendingPlayer.sendMessage(LocaleLoader.getString("Axes.Combat.CritStruck"));
}
}
}
private void calculateSkillModifier() {
this.skillModifier = Misc.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel);
this.skillModifier = SkillTools.skillCheck(manager.getSkillLevel(), Axes.criticalHitMaxBonusLevel);
}
}

View File

@@ -8,46 +8,66 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.util.ItemChecks;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ParticleEffectUtils;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.Users;
public class ImpactEventHandler {
private AxeManager manager;
private Player player;
private EntityDamageByEntityEvent event;
private short durabilityDamage = 1;
private EntityEquipment equipment;
private ItemStack[] armorContents;
private EntityEquipment entityEquipment;
protected LivingEntity defender;
boolean impactApplied;
public ImpactEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) {
this.manager = manager;
this.player = manager.getMcMMOPlayer().getPlayer();
this.event = event;
this.defender = defender;
this.equipment = defender.getEquipment();
this.armorContents = equipment.getArmorContents();
this.entityEquipment = defender.getEquipment();
}
protected void damageArmor() {
protected boolean applyImpact() {
// Every 50 Skill Levels you gain 1 durability damage (default values)
durabilityDamage += (short) (manager.getSkillLevel() / Axes.impactIncreaseLevel);
// getArmorContents.length can't be used because it's always equal to 4 (no armor = air block)
boolean hasArmor = false;
for (ItemStack armor : armorContents) {
if (Misc.getRandom().nextInt(100) > 75) {
for (ItemStack itemStack : entityEquipment.getArmorContents()) {
if (ItemChecks.isArmor(itemStack)) {
hasArmor = true;
for (int i = 0; i <= durabilityDamage; i++) {
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
handleDurabilityEnchantment(armor);
}
if (Misc.getRandom().nextInt(100) < 25) {
damageArmor(itemStack);
}
damageValidation(armor);
armor.setDurability((short) (armor.getDurability() + durabilityDamage));
}
}
equipment.setArmorContents(armorContents);
return hasArmor;
}
private void damageArmor(ItemStack armor) {
// Modifier simulate the durability enchantment behavior
float modifier = 1;
if (armor.containsEnchantment(Enchantment.DURABILITY)) {
modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1;
}
float modifiedDurabilityDamage = durabilityDamage * modifier;
short maxDurabilityDamage = ModChecks.isCustomArmor(armor) ? ModChecks.getArmorFromItemStack(armor).getDurability() : armor.getType().getMaxDurability();
maxDurabilityDamage *= Axes.impactMaxDurabilityDamageModifier;
if (modifiedDurabilityDamage > maxDurabilityDamage) {
modifiedDurabilityDamage = maxDurabilityDamage;
}
armor.setDurability((short) (modifiedDurabilityDamage + armor.getDurability()));
}
protected void applyGreaterImpact() {
@@ -63,30 +83,22 @@ public class ImpactEventHandler {
private void handleGreaterImpactEffect() {
event.setDamage(event.getDamage() + Axes.greaterImpactBonusDamage);
ParticleEffectUtils.playGreaterImpactEffect(defender);
defender.setVelocity(player.getLocation().getDirection().normalize().multiply(Axes.greaterImpactKnockbackMultiplier));
}
private void sendAbilityMessge() {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
if (manager.getMcMMOPlayer().getProfile().useChatNotifications()) {
player.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Proc"));
}
if (defender instanceof Player) {
((Player) defender).sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}
Player defendingPlayer = (Player) defender;
private void handleDurabilityEnchantment(ItemStack armor) {
int enchantmentLevel = armor.getEnchantmentLevel(Enchantment.DURABILITY);
if (Misc.getRandom().nextInt(enchantmentLevel + 1) > 0) {
durabilityDamage--;
}
}
private void damageValidation(ItemStack armor) {
short maxDurability = (short) (armor.getType().getMaxDurability() * Axes.impactMaxDurabilityDamageModifier);
if (durabilityDamage > maxDurability) {
durabilityDamage = maxDurability;
if (Users.getPlayer(defendingPlayer).getProfile().useChatNotifications()) {
defendingPlayer.sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck"));
}
}
}
}

View File

@@ -5,24 +5,20 @@ import java.util.List;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
import com.gmail.nossr50.mods.ModChecks;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public class Excavation {
public static boolean requiresTool = Config.getInstance().getExcavationRequiresTool();
/**
* Check to see if treasures were found.
@@ -32,46 +28,16 @@ public class Excavation {
*/
public static void excavationProcCheck(Block block, McMMOPlayer mcMMOPlayer) {
Material material = block.getType();
int xp;
int xp = Config.getInstance().getXp(SkillType.EXCAVATION, material);
switch (material) {
case CLAY:
xp = Config.getInstance().getExcavationClayXP();
break;
case DIRT:
xp = Config.getInstance().getExcavationDirtXP();
break;
case GRASS:
xp = Config.getInstance().getExcavationGrassXP();
break;
case GRAVEL:
xp = Config.getInstance().getExcavationGravelXP();
break;
case MYCEL:
xp = Config.getInstance().getExcavationMycelXP();
break;
case SAND:
xp = Config.getInstance().getExcavationSandXP();
break;
case SOUL_SAND:
xp = Config.getInstance().getExcavationSoulSandXP();
break;
default:
xp = ModChecks.getCustomBlock(block).getXpGain();;
break;
if (xp == 0 && ModChecks.isCustomExcavationBlock(block)) {
xp = ModChecks.getCustomBlock(block).getXpGain();
}
Player player = mcMMOPlayer.getPlayer();
List<ExcavationTreasure> treasures = new ArrayList<ExcavationTreasure>();
if (Permissions.excavationTreasures(player)) {
if (Permissions.excavationTreasureHunter(player)) {
switch (material) {
case DIRT:
treasures = TreasuresConfig.getInstance().excavationFromDirt;
@@ -109,7 +75,7 @@ public class Excavation {
for (ExcavationTreasure treasure : treasures) {
if (mcMMOPlayer.getProfile().getSkillLevel(SkillType.EXCAVATION) >= treasure.getDropLevel()) {
int activationChance = Misc.calculateActivationChance(Permissions.luckyExcavation(player));
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.EXCAVATION);
if (Misc.getRandom().nextDouble() * activationChance <= treasure.getDropChance()) {
xp += treasure.getXp();
@@ -128,19 +94,8 @@ public class Excavation {
* @param mcMMOPlayer The player using the ability
* @param block The block to check
*/
public static void gigaDrillBreaker(McMMOPlayer mcMMOplayer, Block block) {
Player player = mcMMOplayer.getPlayer();
SkillTools.abilityDurabilityLoss(player.getItemInHand(), Misc.toolDurabilityLoss);
if (!mcMMO.placeStore.isTrue(block) && Misc.blockBreakSimulate(block, player, true)) {
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
Excavation.excavationProcCheck(block, mcMMOplayer);
Excavation.excavationProcCheck(block, mcMMOplayer);
}
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.POP_PITCH);
}
public static void gigaDrillBreaker(McMMOPlayer mcMMOPlayer, Block block) {
Excavation.excavationProcCheck(block, mcMMOPlayer);
Excavation.excavationProcCheck(block, mcMMOPlayer);
}
}

View File

@@ -27,7 +27,7 @@ public class ExcavationCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canGigaDrill = Permissions.gigaDrillBreaker(player);
canTreasureHunt = Permissions.excavationTreasures(player);
canTreasureHunt = Permissions.excavationTreasureHunter(player);
}
@Override

View File

@@ -18,6 +18,7 @@ import com.gmail.nossr50.config.TreasuresConfig;
import com.gmail.nossr50.datatypes.McMMOPlayer;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillTools;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.ItemChecks;
@@ -118,7 +119,7 @@ public final class Fishing {
treasureXp = treasure.getXp();
ItemStack treasureDrop = treasure.getDrop();
if (Permissions.fishingMagic(player) && beginMagicHunter(player, skillLevel, treasureDrop, player.getWorld().hasStorm())) {
if (Permissions.magicHunter(player) && beginMagicHunter(player, skillLevel, treasureDrop, player.getWorld().hasStorm())) {
player.sendMessage(LocaleLoader.getString("Fishing.MagicFound"));
}
@@ -129,7 +130,9 @@ public final class Fishing {
}
mcMMOPlayer.beginXpGain(SkillType.FISHING, Config.getInstance().getFishingBaseXP() + treasureXp);
event.setExpToDrop(event.getExpToDrop() * getVanillaXpMultiplier(skillLevel));
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
event.setExpToDrop(event.getExpToDrop() * getVanillaXpMultiplier(skillLevel));
}
}
/**
@@ -140,7 +143,7 @@ public final class Fishing {
* @return Chosen treasure
*/
private static FishingTreasure checkForTreasure(Player player, int skillLevel) {
if (!Config.getInstance().getFishingDropsEnabled() || !Permissions.fishingTreasures(player)) {
if (!Config.getInstance().getFishingDropsEnabled() || !Permissions.fishingTreasureHunter(player)) {
return null;
}
@@ -160,7 +163,7 @@ public final class Fishing {
FishingTreasure treasure = rewards.get(Misc.getRandom().nextInt(rewards.size()));
ItemStack treasureDrop = treasure.getDrop();
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING);
if (Misc.getRandom().nextDouble() * activationChance > treasure.getDropChance()) {
return null;
@@ -189,7 +192,7 @@ public final class Fishing {
return false;
}
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING);
if (storm) {
activationChance = (int) (activationChance * 0.909);

View File

@@ -51,9 +51,9 @@ public class FishingCommand extends SkillCommand {
@Override
protected void permissionsCheck() {
canTreasureHunt = Permissions.fishingTreasures(player);
canMagicHunt = Permissions.fishingMagic(player);
canShake = Permissions.shakeMob(player);
canTreasureHunt = Permissions.fishingTreasureHunter(player);
canMagicHunt = Permissions.magicHunter(player);
canShake = Permissions.shake(player);
canFishermansDiet = Permissions.fishermansDiet(player);
}

View File

@@ -4,6 +4,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
@@ -17,8 +18,9 @@ import org.bukkit.potion.PotionType;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.skills.utilities.CombatTools;
import com.gmail.nossr50.skills.utilities.PerksUtils;
import com.gmail.nossr50.skills.utilities.SkillType;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
public final class ShakeMob {
private ShakeMob() {}
@@ -31,7 +33,7 @@ public final class ShakeMob {
* @param skillLevel Fishing level of the player
*/
public static void process(Player player, LivingEntity mob, int skillLevel) {
int activationChance = Misc.calculateActivationChance(Permissions.luckyFishing(player));
int activationChance = PerksUtils.handleLuckyPerks(player, SkillType.FISHING);
if (getShakeProbability(skillLevel) <= Misc.getRandom().nextInt(activationChance)) {
return;
@@ -86,6 +88,7 @@ public final class ShakeMob {
break;
}
}
break;
default:
break;
@@ -138,7 +141,7 @@ public final class ShakeMob {
possibleDrops.put(new ItemStack(Material.RED_ROSE), 85);
break;
case MAGMA_CUBE:
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 3);
possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100);
break;
case MUSHROOM_COW:
possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5);
@@ -148,7 +151,7 @@ public final class ShakeMob {
possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30);
break;
case PIG:
possibleDrops.put(new ItemStack(Material.PORK), 3);
possibleDrops.put(new ItemStack(Material.PORK), 100);
break;
case PIG_ZOMBIE:
possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50);
@@ -170,7 +173,7 @@ public final class ShakeMob {
possibleDrops.put(new ItemStack(Material.SNOW_BALL, Misc.getRandom().nextInt(4) + 1), 97);
break;
case SQUID:
possibleDrops.put(new ItemStack(Material.INK_SACK), 100); // TODO: Add DyeColor.BLACK.getDyeData() to make it more explicit (available since 1.4.7-R0.1)
possibleDrops.put(new ItemStack(Material.INK_SACK, 1, DyeColor.BLACK.getDyeData()), 100);
break;
case WITCH:
possibleDrops.put(new Potion(PotionType.INSTANT_HEAL).toItemStack(1), 1);

View File

@@ -3,8 +3,9 @@ package com.gmail.nossr50.skills.herbalism;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.skills.utilities.AbilityType;
import com.gmail.nossr50.skills.utilities.SkillType;
@@ -22,12 +23,10 @@ public class GreenThumbTimer implements Runnable {
@Override
public void run() {
if (this.block.getType() != this.type) {
this.block.setType(this.type);
}
this.block.setType(this.type);
int skillLevel = this.profile.getSkillLevel(SkillType.HERBALISM);
int greenThumbStage = (int) ((double) skillLevel / (double) AdvancedConfig.getInstance().getGreenThumbStageChange());
int greenThumbStage = skillLevel / Herbalism.greenThumbStageChangeLevel;
if (greenThumbStage > 4) {
greenThumbStage = 4;
@@ -39,18 +38,7 @@ public class GreenThumbTimer implements Runnable {
case POTATO:
//This replants the wheat at a certain stage in development based on Herbalism Skill
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
if (greenThumbStage == 3) {
this.block.setData(CropState.MEDIUM.getData());
}
else if (greenThumbStage == 2) {
this.block.setData(CropState.SMALL.getData());
}
else if (greenThumbStage == 1) {
this.block.setData(CropState.VERY_SMALL.getData());
}
else {
this.block.setData(CropState.GERMINATED.getData());
}
this.block.setData((byte) greenThumbStage);
}
else {
this.block.setData(CropState.MEDIUM.getData());
@@ -59,34 +47,37 @@ public class GreenThumbTimer implements Runnable {
case NETHER_WARTS:
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
if (greenThumbStage == 3) {
this.block.setData((byte) 2);
this.block.setData((byte) 0x2);
}
else if (greenThumbStage == 2) {
this.block.setData((byte) 1);
this.block.setData((byte) 0x1);
}
else {
this.block.setData((byte) 0);
this.block.setData((byte) 0x0);
}
}
else {
this.block.setData((byte) 2);
this.block.setData((byte) 0x2);
}
break;
case COCOA:
CocoaPlant plant = (CocoaPlant) block.getState().getData();
if (!this.profile.getAbilityMode(AbilityType.GREEN_TERRA)) {
if (greenThumbStage == 3) {
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
plant.setSize(CocoaPlantSize.MEDIUM);
}
else if (greenThumbStage == 2) {
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
plant.setSize(CocoaPlantSize.MEDIUM);
}
else {
this.block.setData((byte) (this.block.getData() ^ ((byte) 0xc)));
plant.setSize(CocoaPlantSize.SMALL);
}
}
else {
this.block.setData((byte) ((this.block.getData() ^ ((byte) 0xc)) | ((byte) 4)));
plant.setSize(CocoaPlantSize.MEDIUM);
}
block.setData(plant.getData());
break;
default:
break;

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