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

Compare commits

...

271 Commits

Author SHA1 Message Date
Robert A. C
24e4c28355 Updating the readme to reflect current times. 2018-12-24 20:05:18 -08:00
nossr50
6ec61ecb76 Fireworks from ability activation will be Opt-In, updates to strings 2018-12-24 19:05:46 -08:00
nossr50
55a69006bf Merge branch 'master' of https://github.com/mcMMO-Dev/mcMMO 2018-12-24 17:53:03 -08:00
nossr50
8a02230fd2 Updating strings relating to the project. 2018-12-24 17:52:39 -08:00
t00thpick1
2a26b016d9 Only stop monitoring LOG To LOG transitions, there are a ton of non-air block placements we want to monitor 2018-12-24 19:33:26 -05:00
nossr50
7be5b4ecbd Monitor only blocks that replace air. This fixes the TreeFeller interaction with stripped wood. 2018-12-24 00:21:13 -08:00
t00thpick1
565fb35217 Update McmmoCommand.java 2018-12-23 16:40:57 -05:00
LogGits
d2b8c527ad Use dropItem instead of dropItemNaturally (#3644)
This could possibly eliminate a few issues.
2018-12-14 19:51:44 -05:00
LogGits
2cdb17d64f Use dropItem instead of dropItemNaturally (#3645)
Should fix #3641 and #3638
2018-12-14 19:51:38 -05:00
LogGits
96f06ca812 Fixed plugin.yml mistake (#3639)
Accidentally forgot to add the ":" to some of the permissions.
2018-12-09 22:59:16 -05:00
Fabrizio La Rosa
685f6d76a8 Corrected a word (#3629) 2018-12-09 18:29:40 -05:00
LogGits
840cfbe94d Updated plugin.yml to include command permissions (#3637)
This will stop people from seeing the commands in tabcomplete for 1.13.2 if they dont have the permission for it. Should fix #3625.
2018-12-09 18:26:09 -05:00
Josh
605535ed60 fix memory leak (#3631)
on servers with lots of spawner farms this metadata won't get GC'd unless removed, line 436 its added but never removed as far as I can tell
2018-12-06 22:05:55 -05:00
t00thpick1
71c72045b9 Revert "Update locale_zh_CN.properties (#3541)"
This reverts commit eb930883fa.
2018-12-02 23:28:36 -05:00
Ghost_chu
eb930883fa Update locale_zh_CN.properties (#3541) 2018-12-02 23:27:39 -05:00
CNAmira
30ed18eb95 Update Simplified Chinese localization (#3617) 2018-12-02 23:27:19 -05:00
Fabrizio La Rosa
8508f5b8b8 Bug fix for italian locale (#3616)
Fixed the command "/mctop Tiro con l'Arco" that with spaces was not recognized (/mctop archery is not usable if the English locale is not selected).
Now is "/mctop Arco".

That should fix also "/Tiro con l'Arco".
2018-12-02 23:26:58 -05:00
ゆき
dfab223eb2 Fix locale_ja_JP.properties colors (#3628) 2018-12-02 23:26:38 -05:00
Andrewkm
dd82fa0791 Duplicate shulker entry (#3623) 2018-11-26 23:30:08 -05:00
t00thpick1
af8d2dc2c7 Tridents are enchantable 2018-11-26 23:28:15 -05:00
t00thpick1
9f9529debf Has this ever not happened??? I don't understand why it only showed up in 1.13..... Fixes #3564 2018-11-26 23:10:51 -05:00
t00thpick1
495c4a33e5 Store skill totals rather than calculating them on the fly for faster leaderboard queries. 2018-11-14 20:31:57 -05:00
t00thpick1
203d3749ee Fix herbalism XP again 2018-10-14 21:27:55 -04:00
t00thpick1
1fcecbd3e7 Replant only the fully grown plants. 2018-10-13 17:09:08 -04:00
t00thpick1
d778616b2c Herbalism was the one that actually needed to remain blockdata. 2018-10-13 17:06:54 -04:00
t00thpick1
4bdd97a302 Not sure why this is even still here. 2018-10-09 21:57:01 -04:00
t00thpick1
ab2a031ee0 Missed file in commit 2018-10-09 21:56:47 -04:00
t00thpick1
5663b71387 Some of these should not have been blockdata, also this should check age of crops. 2018-10-09 21:52:23 -04:00
ProfLuz
2a43bce849 Fix spectators being affected by a combat ability (#3591)
* Fix spectators being affected by a combat ability
2018-10-01 22:21:22 -04:00
András Marczinkó
592c3a2142 Fix woodcutting double drop item names (#3585) 2018-09-23 14:43:38 -04:00
András Marczinkó
e9ca341476 End_Bricks renamed to End_Stone (#3584) 2018-09-23 11:52:48 -04:00
Captain Justin
76617c8a61 German spelling fix (#3576) 2018-09-23 11:52:35 -04:00
András Marczinkó
10ff097232 Fix config item names (#3583) 2018-09-22 13:45:25 -04:00
Sean Porter
1e043d481a Merge pull request #3582 from andris155/patch-7
Wood renamed to Wooden
2018-09-22 09:54:39 -07:00
Sean Porter
7f8c670dc1 Merge pull request #3581 from andris155/patch-6
QUARTZ_ORE was renamed to NETHER_QUARTZ_ORE
2018-09-22 09:54:24 -07:00
András Marczinkó
0e536a2cb3 Wood renamed to Wooden 2018-09-22 18:53:08 +02:00
András Marczinkó
090cf82a39 Fix Terracotta and stained Terracotta names (#3580) 2018-09-22 12:50:25 -04:00
András Marczinkó
6e60f39f82 QUARTZ_ORE was renamed to NETHER_QUARTZ_ORE 2018-09-22 18:49:02 +02:00
András Marczinkó
b8078e4730 Fix Mycelium name (#3579) 2018-09-22 12:21:23 -04:00
András Marczinkó
e08fe64db2 Fix End Stone name (#3578) 2018-09-22 12:21:13 -04:00
Sean Porter
2b576568a7 QUARTZ_ORE was renamed to NETHER_QUARTZ_ORE. 2018-09-16 18:47:15 -07:00
t00thpick1
e2edbaad34 Update herbalism permissions for new block names. Should fix replanting crops. 2018-09-14 22:44:21 -04:00
t00thpick1
184b98bbdc BREAKING CHANGE - Fix typo in secondary skill enum...... Fixes #2891 2018-09-14 22:36:47 -04:00
t00thpick1
7cc604dbdb Update potions.yml to reflect 1.13 potions and material names. 2018-09-14 20:50:28 -04:00
t00thpick1
44ed35825f more cleanup in the TreasureConfig. 2018-08-30 23:59:55 -04:00
t00thpick1
22833eea6c Slightly delay recipe loading because apparently spigot broke doing that on enable....... 2018-08-30 23:57:29 -04:00
t00thpick1
64dfc1e3d3 Fix hylian drops 2018-08-30 23:28:48 -04:00
nemba246
6619ca1d22 update excavation on experience.yml (#3551)
In 1.13, the name of the grass block changed from "grass" to "grass_block". This caused no experience to be given while using a shovel on grass. This change was part of something mojang called the flattening and could possibly be the cause of some other experience related issues. 
https://minecraft.gamepedia.com/1.13/Flattening
2018-08-30 22:37:01 -04:00
Devon Palma
2f2a80e1ce Various Fixes (#3537)
* Updated ItemUtils, added isBlock check to smelt functions

+ added a check in ItemUtils.isSmeltable() and ItemUtils.isSmelted() to make sure the Item type was a block to prevent an error occuring mentioned in https://github.com/mcMMO-Dev/mcMMO/issues/3536

* Fixed Green Thumb replant issue

see https://github.com/mcMMO-Dev/mcMMO/issues/3535

HerbalismManager
= fixed names of netherwart
= fixed handleBlockState, and slightly altered it
StringUtils
= fixed name of netherwart

* Fixes to herbalism skill

Herbalism
= fixed material name for grass in green terra block conversion
= fixed material name for grass in shroom thumb block conversion
EntityListener
= fixed material name for melon in food level change
experience config
= updated name for melon and sugar cane

* Minor Name Updates

experience config
= removed Stone|*
= added Stone, Granite, Adesite, Diorite
MaterialTypes
= updated material reference for wood

* Small fishing change

PlayerListener
= made it so COD, TROPICAL_FISH, and PUFFERFISH are no longer overwritten, so players can now catch these
2018-08-05 10:15:12 -04:00
Aaron Karras
fa1bbd2031 Updated SkillUtils to no longer use BlockData (#3533) 2018-08-03 18:21:13 -04:00
R4zorax
a39a77f89e Fix fishing in 1.13 (#3528)
* Fix fishing to use Material instead of BlockData (that was AIR)
2018-08-02 20:27:15 -04:00
R4zorax
7800e48f61 Make BiomeAdaptor support Bukkit 1.13 and bump java-version to 1.8 (#3526) 2018-08-01 21:23:29 -04:00
Shane Robertson
63378ae4c1 Updated herbalism (crop replaced by ageable) (#3523)
* [WIP] Replacing MaterialData with Blockdata

* Fixed most block based experience gain

* Removed debug prints

* Updated configs

* [WIP] Replacing MaterialData with Blockdata

* Fixed most block based experience gain & updated wooden_tools

* ACTAULLY removed debug prints

* [WIP] Replacing bukkit treespecies 

This feature has been unofficially deprecated, (not yet fixed/marked in bukkit)
Also updated config.yml to match changes

* Updated configs

* [WIP] Replacing MaterialData with Blockdata

* [WIP] Replacing MaterialData with Blockdata

* Fixed most block based experience gain

* Fixed most block based experience gain & updated wooden_tools

* Removed debug prints

* ACTAULLY removed debug prints

* [WIP] Replacing bukkit treespecies 

This feature has been unofficially deprecated, (not yet fixed/marked in bukkit)
Also updated config.yml to match changes

* Fixed greenterra

Replaced deprecated features
2018-07-31 21:35:45 -04:00
t00thpick1
fecf83c79c Don't break on double drops for woodcutting. 2018-07-30 20:44:10 -04:00
t00thpick1
f287b6d8a7 Update fishing experience config 2018-07-27 22:30:57 -04:00
Leomixer17
9082658357 Update locale_it.properties (#3509) 2018-07-27 18:28:44 -04:00
Shane Robertson
4bda175328 Removed misc, print statements (#3508)
* ACTAULLY removed debug prints
2018-07-26 20:47:45 -04:00
Shane Robertson
ee324c77a9 Fixed errors with block-based skill experience (#3506)
* Updated configs

* [WIP] Replacing MaterialData with Blockdata

* Fixed most block based experience gain

* Fixed most block based experience gain & updated wooden_tools

* Removed debug prints
2018-07-26 19:53:29 -04:00
Jamie Sinn
210b418e44 Get string before format. (#3507) 2018-07-26 19:52:15 -04:00
t00thpick1
b73eced36f Remove sound adapter 2018-07-25 20:29:40 -04:00
shanedrgn
6296a6adde Updated configs
Signed-off-by: t00thpick1 <t00thpick1dirko@gmail.com>
2018-07-25 20:20:31 -04:00
Leomixer17
99f6192965 Update locale_it.properties (#3502) 2018-07-25 19:53:23 -04:00
t00thpick1
bff454f397 Wood is not planks. 2018-07-24 20:50:17 -04:00
t00thpick1
8216dbe355 This is kinda important 2018-07-23 22:38:05 -04:00
t00thpick1
fbe26af2d7 Merge remote-tracking branch 'origin/master' 2018-07-23 22:14:44 -04:00
t00thpick1
0a1559511a Quick and dirty 1.13 update. I.e. it now compiles for 1.13. 2018-07-23 22:13:57 -04:00
Jamie Sinn
aee60f2c09 Mctop Cooldown message correction. Closes https://github.com/mcMMO-Dev/mcMMO/issues/3470 (#3481) 2018-07-15 10:08:52 -04:00
FabioZumbi12
9ce850f84f Re-added handlersList to event. (#3234) 2018-06-13 20:50:46 -04:00
t00thpick1
cbff8482ce Merge pull request #3427 from joblo2213/master
Add McMMOPlayerSalvageCheckEvent
2018-06-09 11:50:32 -04:00
joblo.2213
0035762a71 Add McMMOPlayerSalvageCheckEvent 2018-06-09 09:46:06 +02:00
t00thpick1
3d515aab23 Bump version 2018-05-25 22:52:10 -04:00
Glitchfinder
e77801f3c1 Ensure all entity types function in experience.yml
Fixes #3443
2018-05-16 08:07:07 -07:00
Glitchfinder
c83d011faa Don't convert raw salmon to raw fish when summoning ocelots.
Fixes #3366
2018-05-15 19:40:48 -07:00
Glitchfinder
5aa4949baa Allow experience on crops grown with bonemeal. 2018-05-15 11:31:52 -07:00
Glitchfinder
906ead53dd Merge branch 'patch-1' of github.com:ChrisLane/mcMMO 2018-05-11 10:09:37 -07:00
Glitchfinder
cbcdedc67a Merge branch 'patch-1' of github.com:MiniDigger/mcMMO 2018-05-11 10:08:26 -07:00
Glitchfinder
c87b410823 Merge branch 'anvil_unbreakables' of github.com:GiovanH/mcMMO 2018-05-11 10:07:53 -07:00
Glitchfinder
0a447f68c6 Merge branch 'patch-2' of github.com:GiovanH/mcMMO 2018-05-11 10:06:58 -07:00
Glitchfinder
e98d241452 Merge branch 'master' of github.com:ProgrammingAtDawn/mcMMO 2018-05-11 10:04:14 -07:00
GiovanH
421455224f Codebase! 2018-05-10 04:54:35 +01:00
t00thpick1
29c55312a5 Don't allow these commands on child skills. 2018-05-01 23:12:06 -04:00
Gio
6c474c8838 Added nether bricks to mining
As per https://github.com/mcMMO-Dev/mcMMO/issues/3426
2018-04-30 20:38:01 -05:00
t00thpick1
03182ea24c Merge pull request #3440 from GiovanH/patch-1
Handle playerdata without bukkit.lastKnownName info
2018-04-30 18:38:08 -04:00
Gio
2c6543da9e More descriptive text. 2018-04-30 13:30:41 -05:00
Gio
20bbdfc4ab Check playerdata for corruption
Fixed a null pointer exception that would occur if the offlinePlayer object did not have a defined string for .getName();
2018-04-30 12:54:35 -05:00
Glitchfinder
5b2ebf4aa8 Prevent shulker boxes from activating abilities.
Fixes #3438.
2018-04-29 23:09:52 -07:00
t00thpick1
2b159adefd Merge pull request #3330 from hoorigan/ench-book-fixes
Enchanted book fixes
2018-04-28 20:04:06 -04:00
Glitchfinder
be2de1d487 Fix a duping bug that uses a coordinate error. Fixes #2979 and fixes #3429. 2018-04-15 10:19:31 -07:00
t00thpick1
6876f192de Deflag blocks when they grow, Fixes #3311, #3207 2018-04-07 13:41:20 -04:00
t00thpick1
875db44afd Don't active skills on shulker blocks Fixes #3423 2018-04-07 13:33:28 -04:00
t00thpick1
2e120abe3a Merge pull request #3395 from ezeiger92/master
Fix a couple tickets
2018-02-15 23:00:30 -05:00
ezeiger92
feeb17d6f0 Scale fishing drop chance by lure rather than subtracting 1
Fixes mcMMO-Dev/mcMMO#3383
Added config option for lure enchantment modifier
Fixes lure enchantment having no effect on drops from offhand
2018-02-15 15:48:21 -08:00
ezeiger92
6d2003d577 Remove offhand fishing rod if not in main hand
Fixes mcMMO-Dev/mcMMO#3342
Fixed style error in last commit
2018-02-15 13:59:10 -08:00
ezeiger92
40b609ccd8 Respect unbreakable tag on items when attempting durability changes
Fixes mcMMO-Dev/mcMMO#3327
Fixes mcMMO-Dev/mcMMO#3391
2018-02-15 13:38:10 -08:00
ProgrammingAtDawn
d64399df49 Calculate experience gain before processing green thumb. 2018-01-24 20:53:59 +01:00
t00thpick1
d4f2f0e11b Use new recipe constructor to avoid deprecation errors. 2017-12-17 13:31:30 -05:00
hoorigan
916d9a7c8a ItemUtils: add ENCHANTED_BOOK to isEnchantable()
This will (hopefully) make mcMMO aware that ENCHATED_BOOK can have an enchantment.
2017-10-31 16:47:46 -04:00
hoorigan
6d5ab0edda FishingManager: force enchant on enchanted book
Added a small conditional to ensure that enchanted books get an enchantment.
2017-10-31 16:45:08 -04:00
t00thpick1
307d483323 Dont do diminishing returns on command caused xp gains Fixes #3312 2017-10-27 20:30:56 -04:00
t00thpick1
eb4960f307 Merge pull request #3300 from EasyMFnE/master
Add automatic Alchemy potion colorization and custom color config
2017-10-05 19:44:47 -04:00
t00thpick1
9df72e61a2 Mob Health bars global toggle 2017-10-03 23:32:54 -04:00
EasyMFnE
fcb6391ba3 Remove leftover debug code. 2017-09-28 11:44:15 -04:00
EasyMFnE
16a77f281e Add automatic Alchemy potion colorization and custom color configuration. 2017-09-23 15:35:38 -04:00
t00thpick1
87ebf7023f Additional changes that are less important but related to the dupe fix. 2017-09-12 20:01:09 -04:00
t00thpick1
028f87653a Check length of the Y dimension of the array, not the x dimension, which will only be 16 2017-09-08 23:16:41 -04:00
t00thpick1
0e51983819 Y, not Z, very very important. 2017-09-06 00:23:35 -04:00
t00thpick1
c174f2b829 Back to development 2017-09-05 20:57:25 -04:00
t00thpick1
8e9d393eb2 Bump version 2017-09-05 20:51:24 -04:00
t00thpick1
f1f02fd005 Don't fail out of saves just because a single player fails. 2017-09-01 00:45:22 -04:00
t00thpick1
f279a979e3 Also handle bottom of world 2017-09-01 00:44:37 -04:00
t00thpick1
e0bbe9cea4 Fix error with pistons retracting near top of world. Fixes #3172 2017-09-01 00:43:11 -04:00
t00thpick1
d3cc23f6a0 Fix smelting vanilla xp boost. Fixes #3270 2017-09-01 00:32:11 -04:00
t00thpick1
4c3f3ee4e2 Dont use named seeds in replanting. Fixes #3273 2017-08-31 23:47:28 -04:00
t00thpick1
2d7c5d7fd6 Merge pull request #3279 from ezeiger92/master
Pull downstream changes
2017-08-31 00:08:32 -04:00
t00thpick1
8be68aa6df Merge pull request #3252 from ezeiger92/fix-3250
Fix 3250
2017-08-31 00:02:37 -04:00
Erik
a731ad14ec Merge pull request #1 from ezeiger92/many-fixes
Pull in fixes
2017-08-15 21:44:49 -07:00
Erik
05ca96aa7f Build against 1.12.1 to NOT break getTargetBlock 2017-08-15 16:45:32 -07:00
Erik
60aa32d003 Patches!
* Update bukkit version
* Default vanilla  exp modifier for fishing is now 1
* Fixed beetroot permission for herbalism
2017-08-15 12:20:09 -07:00
Erik
0e7ee41444 Follow spacing convention 2017-08-05 11:53:38 -07:00
Erik
b5f6b1d97f Fix for 3250 - HashSet<Byte> to HashSet<Material> for getTargetBlock 2017-08-05 11:50:24 -07:00
t00thpick1
f1ac5739e4 [bugfix] Resolve issues with Herbalism exp.
Due to flaws the previous changes to the configuration system combined with some bad lines in the experience.config that I mistakenly recommended, herbalism was not granting experience in most cases, as it was marking newly planted crops and such as player placed no exp granting blocks, rather than ignoring them as it should.
block types now are evaluated in 3 steps:
1: Explicit Name  i.e. ("Crops|4", "Crops|0"), Which is the material name then data value
2: "friendly name"  i.e. ("Crops_Ripe", "Crops_Ungrown"), Which is a typically data valueless name,  some of which I make up in mcMMO, but most of which are just the Material name
3: Wildcard name  i.e. ("Crops|*") Which is any block with that block value, regardless of data value

In order to be sure herbalism grants exp for you once again, make sure your configuration for herbalism looks similar to this:
https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/resources/experience.yml#L151

In terms of which blocks are listed there.  Specifically, there should be no blocks marked "ungrown"
2017-08-01 01:33:02 -04:00
t00thpick1
8cbb57df97 Fix herbalism I think 2017-07-23 18:06:45 -04:00
t00thpick1
2c8d2998bb Merge pull request #3201 from wysohn/master
HandlerList should be present in every Events. (It's static you know)
2017-06-28 08:59:52 -04:00
t00thpick1
44684fcfd0 Fix green thumbing plants to grow. They need to be in the config to be used, but at 0 exp so we don't gain exp off them 2017-06-27 20:26:55 -04:00
t00thpick1
7081e03c23 Back to dev 2017-06-27 20:26:30 -04:00
t00thpick1
246db98519 bump version 2017-06-26 20:56:34 -04:00
Chris Lane
ee245d348f Remove duplicate "Beetroot_block" option 2017-06-23 14:34:24 +01:00
wysohn
f718741044 HandlerList should be present in every Events. (It's static you know) 2017-06-17 20:16:09 -07:00
t00thpick1
c054ff851a Fix excavation treasures 2017-06-14 21:14:09 -04:00
t00thpick1
755787f9ee Add sapling types 2017-06-10 14:30:06 -04:00
t00thpick1
24f8b2fbd5 More configuration for hylian luck 2017-06-10 14:16:31 -04:00
t00thpick1
ee02a19e9a Add more configuration to shake treasures 2017-06-10 13:59:49 -04:00
t00thpick1
cb5d38c11f Leftover debug 2017-06-10 13:49:19 -04:00
t00thpick1
15436b44da Update configurations and skill block checks to be more configurable. 2017-06-10 13:47:20 -04:00
t00thpick1
5c267663a2 Merge pull request #3160 from filoghost/patch-1
Fix permission error
2017-06-07 21:24:00 -04:00
t00thpick1
fda625b235 Merge pull request #3185 from nathanprocks/master
Add shaking from shulkers
2017-06-07 21:22:30 -04:00
t00thpick1
2cbd8789d8 Merge pull request #3175 from lucko/master
Fix for removed methods in Bukkit 1.12
2017-06-07 21:22:00 -04:00
Nathan Piercy
95167f44f1 Add shaking from shulkers 2017-06-04 16:34:48 +10:00
Luck
789b51fd05 Fix for removed methods in Bukkit 1.12 2017-05-14 16:36:31 +01:00
filoghost
0911c86422 Prevent players from resetting each other's skills
The child permission has the value set to false. From http://bukkit.gamepedia.com/Plugin_YAML: "a child node of false inherits the inverse parent permission". Having the value set to false grants the permission to reset other players' skills to everyone that doesn't have the mcmmo.skillreset permission, which by default nobody has.
2017-04-24 20:17:43 +02:00
t00thpick1
7d05c9d8e6 Add some more defaults into the config. Remove the parts that delete keys, I don't maintain config files well enough to have them remove unknown keys. 2017-04-15 00:24:39 -04:00
t00thpick1
a43ae4178a Some cleanups to mob related XP code 2017-04-15 00:04:07 -04:00
t00thpick1
c9c2c483fa Remove unneccessary code. 2017-04-14 23:34:54 -04:00
t00thpick1
133281faaa Merge pull request #3131 from TheComputerGeek2/master
Prevent disarming, bleed, and axe passives when dealing thorns damage
2017-04-14 23:26:49 -04:00
MiniDigger
ef8987917d Fix avatars in readme, link can't be in new line 2017-04-07 08:25:23 +02:00
TheComputerGeek2
d6a00eaf00 Prevent disarming, bleed, and axe passives when dealing thorns damage 2017-03-06 18:03:15 -08:00
t00thpick1
69151f0855 Forgot to actually add the funfetti 2017-02-22 00:01:39 -05:00
t00thpick1
bb27d753b1 I think this should stop my fireworks from damaging people 2017-02-22 00:00:47 -05:00
t00thpick1
37ce29a5e8 Merge pull request #3094 from SupaHam/fix-chimaera-tp-cancel
Set TeleportCommenceLocation to null after Chimaera cancellation.
2017-01-15 22:19:51 -05:00
t00thpick1
6297e1c79b Merge pull request #3104 from kanesada2/skeleton
Fix shake from WITHER-SKELETON. avoid to use depredated method: getSkeltonType().
2017-01-15 22:18:26 -05:00
kanesada2
4e2903e65c I used wrong treasure.yml... 2017-01-13 14:28:54 +09:00
kanesada2
2e7f56eeb5 fix shake for WITHER-SKELETON. avoid to use getSkeltonType() 2017-01-13 14:10:55 +09:00
Ali Moghnieh
7e46d5ca08 Set TeleportCommenceLocation to null after Chimaera cancellation.
This makes the item usable once again, as the prechecks check to make sure the location is null.
2016-12-26 21:26:38 +00:00
t00thpick1
a2bcce9ab1 I believe this resolves berserk allowing you to take drops into your equipment slots. 2016-12-17 17:32:16 -05:00
t00thpick1
2f7b1c38e1 Snapshot again 2016-12-04 21:54:11 -05:00
t00thpick1
789aaec186 I should probably compile before committing in the future. 2016-12-04 21:42:26 -05:00
t00thpick1
f3d6c1727b 1.5.07 - The "Thanks @TheBentoBox for the brewing fix" update 2016-12-04 21:40:30 -05:00
t00thpick1
c029b51c97 Doesn't look like CI handles this anymore :( 2016-12-04 21:39:15 -05:00
t00thpick1
6c5fb5f398 Fix entity kill xp 2016-12-04 20:53:51 -05:00
t00thpick1
4b20db47b2 Update spigot version 2016-12-02 00:12:16 -05:00
t00thpick1
e238ec8fc6 Merge pull request #3067 from TheBentoBox/master
Fix 1.11 brewing, remove health bar from armor stands
2016-12-01 00:54:39 -05:00
t00thpick1
9689f55e5c Merge pull request #3055 from jjm223/bugfix/fuel
Rapid fuel consumption fix
2016-12-01 00:54:32 -05:00
t00thpick1
ec0c7da494 Merge pull request #3050 from MLG-Fortress/master
Don't handle item pickups when Items_As_Unarmed is set to true
2016-12-01 00:54:23 -05:00
Jake Ben-Tovim
5f9f3e8167 Fix 1.11 brewing, remove health bar from armor stands
This fixes brewing on the newest Spigot API builds. The Alchemy skill was completely broken due to a change in the Spigot BrewEvent constructor, which this fixes via the changes to FakeBrewEvent.java and AlchemyPotionBrewer.java. This also adds a check in EntityListener.java for armor stands, so that health bars aren't displayed for them. The health bars never really displayed properly (armor stand health acts differently from most entities), and it allowed players to punch invisible armor stands server admins may have been intentionally hiding to temporarily reveal them via a health bar, which is an issue.
2016-11-28 21:28:05 -05:00
Jacob Martin
6388246418 Fix an issue where brewing stands will consume two fuel units for vanilla ingredients. 2016-11-13 10:26:29 -06:00
RoboMWM
86432eb426 Don't handle item pickups when Items_As_Unarmed is set to true
If `unarmed.Items_As_Unarmed` is set to true in config, then there's no
need to be manually handling item pickups.
2016-10-23 22:38:31 -07:00
t00thpick1
a51585f5d0 Merge pull request #3007 from FabioZumbi12/master
Fix pt-br strings
2016-08-20 22:00:05 -04:00
t00thpick1
9ec75fb470 Back to dev 2016-08-20 21:54:09 -04:00
t00thpick1
c8a7f6d76f Version Bump 2016-08-20 21:50:43 -04:00
t00thpick1
01a8a199d2 Fix a dupe bug that resulted from yet another change to piston code a couple mc patches ago. Oh well. 2016-08-20 21:47:29 -04:00
t00thpick1
f85c54596a Merge pull request #3011 from SidShakal/patch-chunkRefreshRadiusFix
Correcting loop conditions related to "ghost block" mitigation.
2016-08-07 20:55:09 -04:00
Sid Shakal
b3e1acc563 Correcting conditions related to "ghost block" mitigation.
If radius is 1 (as it is when called elsewhere in the class), the loop
conditions fail to refresh some of the neighboring chunks, allowing for
ghost blocks to continue to occur on eastern and southern edges of the
chunk the player is in.

This commit fixes the loop conditions.

= Chunk diagram of old behavior =
-----
-RR--
-RP--
-----
-----

= Chunk diagram of new behavior =
-----
-RRR-
-RPR-
-RRR-
-----

= Legend =
P: the chunk the player is in
R and P: chunks that are refreshed
-: chunks that do not get refreshed
2016-08-07 17:32:34 -05:00
FabioZumbi12
745ff21551 Merge pull request #2 from FabioZumbi12/FabioZumbi12-patch-1
Fix translated strings
2016-08-05 09:59:52 -03:00
FabioZumbi12
31c8cf9766 Fix translated strings
Fix translated strings
2016-08-05 09:59:39 -03:00
t00thpick1
8901db4e18 Add Beetroot to herbalism skill
Merge pull request #2918 from isokissa3/master

His was better.

(cherry picked from commit 3ed0fdf330)
2016-06-26 17:14:19 -04:00
t00thpick1
b1b8c4d713 Back to dev 2016-06-25 13:05:47 -04:00
t00thpick1
b14b37c22d Version bump 2016-06-25 13:00:47 -04:00
t00thpick1
e73e628051 Merge pull request #2951 from minoneer/brewing-fuel
Fix brewing stands consuming all remaining fuel items
2016-06-25 12:53:20 -04:00
t00thpick1
3bb920f22c This is completely untested but it probably works. Maybe Fixes #2966 2016-06-23 21:22:40 -04:00
t00thpick1
2bed26f18a Fix scoreboard numbering being off 2016-06-19 17:47:38 -04:00
t00thpick1
fb3363661b Remove invalid enchantment from default config 2016-06-19 17:42:40 -04:00
t00thpick1
315b713005 These should definently not be hard coded in the future... but allow rabbits and guardians to be shaken down 2016-06-19 17:41:18 -04:00
t00thpick1
70de0ba00b Enable Beetroot I think 2016-06-19 17:33:43 -04:00
minoneer
25cad3afc6 Fix brewing stands consuming all remaining fuel items when the fuel bar is refilled 2016-06-09 02:10:27 +02:00
t00thpick1
11aa126b80 Merge pull request #2918 from isokissa3/master
Exploit fix, turning spawned pigs into zombie pigmans using lightning stike allows you gain XP
2016-04-28 10:31:24 -04:00
isokissa3
d0e8bb3174 Fixed spacing 2016-04-27 13:45:26 +03:00
isokissa3
6b03108052 Fixed formatting 2016-04-26 15:26:50 +03:00
isokissa3
34447ef874 Exploit fix, turning spawned pigs into zombie pigmans using lightning stike allows you gain XP 2016-04-25 18:47:15 +03:00
t00thpick1
dcd79e87e1 This command probably works 2016-04-23 00:32:04 -04:00
t00thpick1
8822b4edae Fix typo 2016-04-03 00:25:50 -04:00
t00thpick1
a24d6ff018 Missed removals 2016-03-27 11:46:00 -05:00
t00thpick1
707195f237 I honestly forgot this was in here. Fixes #2863 2016-03-27 11:12:16 -05:00
t00thpick1
321fcd7b84 Merge pull request #2850 from DylanCare/master
Fixes Alchemy for Stage 1 Potions and Lingering
2016-03-23 21:21:51 -05:00
Dylan
c5970e9246 Ensure NETHER_WARTS are renamed to NETHER_STALK 2016-03-21 14:42:57 -04:00
Dylan
538a0c5d6c Fixes Stage 1 Potions
The 'NETHER_WARTS' material enum should be 'NETHER_STALK' to represent the actual item.
Adds Dragon's Breath as Tier 1 Ingredient so lingering potions are actually validated as an mcMMO brew.
Adds second type of Potion of Water to support water potions that are spawned in via commands or other plugins.
2016-03-21 14:38:58 -04:00
t00thpick1
4c4df60b81 Was in a second location as well. 2016-03-20 17:52:21 -05:00
t00thpick1
d1cf08c6ba Null check. Fixes #2840 #2842 2016-03-20 12:47:27 -05:00
t00thpick1
e091a8eb55 Fix material validation errors. 2016-03-20 12:42:16 -05:00
t00thpick1
d579c9a2af Merge pull request #2829 from DorCoMaNdO/master
Stop duplicate messages from abilities.
2016-03-17 19:38:55 -05:00
Dor
a711d3a3e3 Stop duplicate messages from abilities. 2016-03-18 02:18:40 +02:00
Dor
2c197af9fd Merge remote-tracking branch 'refs/remotes/mcMMO-Dev/master' 2016-03-18 02:17:03 +02:00
t00thpick1
d58d621f96 Bump java compat version (reverted from commit 0203252b63) 2016-03-17 16:57:27 -05:00
t00thpick1
0203252b63 Bump java compat version 2016-03-17 16:52:41 -05:00
t00thpick1
22edd121d3 Back to dev 2016-03-17 12:36:32 -05:00
t00thpick1
31b83becad Version bump 1.5.04 2016-03-17 12:36:08 -05:00
t00thpick1
6cce3098db Update PotionConfigGenerator and default potions.yml for missing potions 2016-03-17 12:31:20 -05:00
t00thpick1
fd3d60d112 Merge pull request #2828 from SidShakal/master
Moved center of block drops to block center. Fixes #2544.
2016-03-17 11:16:24 -05:00
t00thpick1
9094e5feb8 French Translation update provided by @HollishKid Resolves #2819 2016-03-17 12:12:22 -05:00
Sid Shakal
60bfabb097 Moved salvaged material spawn center to center of top face of anvil.
My fix for the central spawn points of various block-based item drops
moved them from the low corner of the block to the center of the block.
In the case of the salvaged materials, this moved the central spawn
point from the low corner of the top face of the anvil block to the
center of the block above the anvil block. This felt unnatural, so the
point has been moved to the center of the top face of the anvil block.
2016-03-17 02:06:19 -05:00
Sid Shakal
2d4cf76825 ... (completing the previous style fix)
Not sure how I missed this one. (Well, sure I do. I used the GitHub
editor for the re-casing of the variable name. Noob mistake.)
2016-03-16 20:38:24 -05:00
t00thpick1
6a7279ea05 Merge pull request #2824 from DorCoMaNdO/master
Custom potion brewing now consume fuel from the brewing stand.
2016-03-16 18:07:45 -05:00
Sid
4cb4a6224b Added javadoc for Misc.getBlockCenter(BlockState)
And camel-cased the parameter name to conform to style.
2016-03-16 15:47:24 -05:00
Sid Shakal
a6e445b7ef Minor formatting adjustments to keep my commit to code style.
Whoops. Eclipse removed a line in imports, and I placed a brace on the
wrong line. Fixed.
2016-03-16 12:01:52 -05:00
Sid Shakal
123a139e43 Moving the center of block drops to block center. Fixes #2544. 2016-03-16 11:47:40 -05:00
Dor
4054315c19 Custom potion brewing now consume fuel from the brewing stand.
Fixed a glitch that let players remove the ingredient of a custom potion
from the brewing stand without cancelling the brewing task (this doesn't
seem to have caused any duplicates, once the task finished nothing
happened).
2016-03-16 15:16:48 +02:00
Dor
d942cedb8e Merge remote-tracking branch 'refs/remotes/mcMMO-Dev/master' 2016-03-16 15:11:51 +02:00
t00thpick1
ec774b590b Fix potions. Fixes #2813, #2814 2016-03-16 00:39:36 -05:00
Dor
988a11a5da Merge remote-tracking branch 'refs/remotes/mcMMO-Dev/master' 2016-03-13 01:11:51 +02:00
t00thpick1
1488946fc5 Merge pull request #2694 from Maximvdw/patch-1
Fixed NPE when skill is not in config
2016-03-12 17:56:40 -05:00
t00thpick1
1f05967b0b Merge pull request #2725 from EvilOlaf/patch-3
Fix space and color code
2016-03-12 17:56:11 -05:00
t00thpick1
4924391ae8 Merge pull request #2726 from JamieSinn/master
If sender is console, strip colours for mctop
2016-03-12 17:55:59 -05:00
t00thpick1
f2668d7dbb Merge pull request #2735 from EvilOlaf/patch-2
fixed typo
2016-03-12 17:55:46 -05:00
t00thpick1
d26779bee9 Merge pull request #2810 from DorCoMaNdO/master
Fix Shroom Thumb not removing the item held.
2016-03-12 17:55:35 -05:00
t00thpick1
c75715b186 We need to name the custom potions. 2016-03-12 17:52:19 -05:00
t00thpick1
a238b7029d Update default potions.yml and add tool to do so in the future. 2016-03-12 17:45:14 -05:00
Dor
98511136ee Fix Shroom Thumb not removing the item held. 2016-03-12 20:35:19 +02:00
t00thpick1
6723b3a4c6 Merge pull request #2803 from DorCoMaNdO/master
Treat grass path as grass...
2016-03-12 12:17:04 -05:00
Dor
40c61149cf Treat grass paths as grass. 2016-03-12 08:12:27 +02:00
Dor
4f9a463b9d Merge remote-tracking branch 'refs/remotes/mcMMO-Dev/master' 2016-03-12 08:03:30 +02:00
t00thpick1
f3a8208425 Add new enchants and fallback to bukkit enchant name map 2016-03-11 22:55:01 -05:00
t00thpick1
cbf2f34f93 Update Treasures for potions 2016-03-11 22:42:55 -05:00
t00thpick1
898fad6be4 Merge pull request #2801 from DorCoMaNdO/master
Chorus plant experience reward is now 1 instead of 2.
2016-03-11 22:38:46 -05:00
Dor
eaa1a8edca Chorus plant experience reward is now 1 instead of 2.
Sneaking is required if the player has an item in the off hand and
they're not in a vehicle.
2016-03-12 05:31:11 +02:00
Dor
08db154791 Merge pull request #3 from mcMMO-Dev/master
Merge master
2016-03-12 05:29:35 +02:00
t00thpick1
e1cf4c0c67 Merge pull request #2800 from DorCoMaNdO/master
Fix config auto update.
2016-03-11 22:21:59 -05:00
Dor
529c43b0e6 Fix config auto update. 2016-03-12 05:10:41 +02:00
t00thpick1
376abdf49e Merge pull request #2799 from DorCoMaNdO/patch-3
Use getItemInMainHand()
2016-03-11 22:09:08 -05:00
t00thpick1
11a744a772 Properly calculate potionstage 2016-03-11 22:07:27 -05:00
Dor
47f73ba455 Merge pull request #2 from mcMMO-Dev/master
Merge master
2016-03-12 05:05:37 +02:00
t00thpick1
001b11efc6 Better Auto-Update config loader, still cannot handle multiple options with the exact same name and spacing, but will not break configs anymore in those situations, just mis-comment. 2016-03-11 21:54:57 -05:00
t00thpick1
089f3a0e71 Does this fix the CI? (reverted from commit af9a3c85c6) 2016-03-11 21:30:11 -05:00
t00thpick1
af9a3c85c6 Does this fix the CI? 2016-03-11 21:28:46 -05:00
t00thpick1
a534f9aac1 Update default Potions.yml to have some of the new format, someone should PR a full update. 2016-03-11 21:15:22 -05:00
t00thpick1
a08016647a Update to new Potions API, still supports old config options 2016-03-11 21:08:10 -05:00
Dor
a557fc7d3c Use getItemInMainHand()
Add 1.9 blocks to be detected for experience rewards.
Add experience rewards for the Chorus plant.
Add experience rewards for the Shulker mob.
2016-03-11 16:20:23 +02:00
Dor
2d3d11ec2d Merge pull request #1 from mcMMO-Dev/master
Merge master
2016-03-11 06:01:08 +02:00
t00thpick1
9bc97c6dd3 I think this fixes the auto update config function when a config file has two similar keys. (reverted from commit 52f1e33052) 2016-03-08 08:09:48 -05:00
t00thpick1
52f1e33052 I think this fixes the auto update config function when a config file has two similar keys. 2016-03-07 18:41:49 -05:00
t00thpick1
272e99d41f Master volume config option 2016-03-06 16:48:56 -05:00
t00thpick1
77b67d5a79 Merge pull request #2781 from Tslat/patch-1
Fix infinite GreenThumb & ShroomThumb usage bug

-Not sure if this is the correct way to fix this, but it is A way, and that will due in the meantime.
2016-03-05 23:57:25 -05:00
t00thpick1
8e1f464209 Merge pull request #2783 from Tslat/patch-2
Update ability blacklist to include 1.8 fence[gate] types
2016-03-05 23:56:08 -05:00
Tslat
5f960fd80a Update ability blacklist to include 1.8 fence[gate] types 2016-03-06 14:36:21 +10:00
Tslat
bddca30668 Fix infinite GreenThumb & ShroomThumb usage bug 2016-03-05 20:39:16 +10:00
t00thpick1
28a2b9668d I think preserve potions backwards compatability and also update documentation. 2016-03-01 17:16:59 -05:00
t00thpick1
f52d9feef8 Update Alchemy for 1.9 Configuration style has changed, but theoretically old version should still work I think. 2016-03-01 17:05:58 -05:00
t00thpick1
f77ae6ee15 Biome needs to be in the enum compatability as well. 2016-03-01 13:25:51 -05:00
t00thpick1
88b99a3835 I *think* this should be backwards compatible, I may be wrong and it could break both. 2016-03-01 13:08:11 -05:00
t00thpick1
8d16af8770 Why is my local compiler missing thigns the CI hits? 2016-03-01 12:42:26 -05:00
t00thpick1
fde9ba86a2 Actually update all sounds 2016-03-01 12:39:05 -05:00
t00thpick1
c9356f9ef5 Update for 1.9 Sound enum changes. Now only compatible with 1.9+ 2016-03-01 12:21:00 -05:00
t00thpick1
6a0529f02d Fully remove metrics. 2016-01-28 15:20:36 -05:00
t00thpick1
760178c061 Give custom perk boost the highest priority. 2016-01-28 13:37:21 -05:00
t00thpick1
0bb2642d24 Remove metrics 2016-01-11 14:12:54 -05:00
Very Evil Olaf
635a4f7265 fixed typo
smelt = Schmelzung, not Schmelung
2015-12-28 20:18:55 +01:00
Jamie Sinn
0e34202d4d Curly braces as toothpick requested
@andrewkm
2015-12-20 23:05:48 -05:00
JamieSinn
3a9c55a9ea Remove ternary operators and use if/else 2015-12-12 00:04:23 -05:00
JamieSinn
2dd1775d9a Remove regex replace, does nothing 2015-12-11 23:52:14 -05:00
JamieSinn
a0635eeb08 Remove escape character at EOL 2015-12-11 23:45:17 -05:00
JamieSinn
9677653c54 If sender is console, strip colours for mctop
Ugly ugly colours.
2015-12-11 23:30:21 -05:00
Very Evil Olaf
6cf7167c09 Fix space and color code 2015-12-10 21:37:42 +01:00
Maxim Van de Wynckel
f9879be439 Fixed NPE when skill is not in config
When a skill is not configured this would throw an NPE as the section is not found.

Found while trying to get information from an McMMOLevelUp event
2015-09-27 00:50:26 +02:00
121 changed files with 6292 additions and 4402 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
/.classpath
/.project
/.settings
/dependency-reduced-pom.xml
# netbeans
/nbproject

View File

@@ -7,18 +7,34 @@ Key:
! Change
- Removal
Version 1.5.04-SNAPSHOT
Version 2.0.00
= Fixed an interaction between Tree Feller and Stripped Wood
! Fireworks no longer fire by default for ability activation/deactivation
! Website has been changed and the MOTD string relating to it reflects this
! Discord link added to mcMMO command
! Updated misc strings relating to mcMMO
Version 1.5.05-SNAPSHOT
Version 1.5.04
+ Added option to config.yml to control mcMMO generated sound volume
+ Added option to config.yml to truncate existing player skill levels that exceed the skill level cap
+ Falling blocks persist mcMMO natural data
= Woodcutting double drops correctly identify acacia and dark oak logs
= Skill Reset command now correctly identifies arguments
= Hylian Treasure config options are now actually used
= Child skills now use parent skills configured skill caps properly
= Auto Update config now properly works
! Item dropped from blocks now drop from the center
! Potions Config updated for 1.9
! Flux mining now simulates a block break event for other plugins to act upon
! Zombie Pigmen spawned from nether portals are now considered spawner mobs
! Flux Pickaxe lore now appends to existing lore as opposed to replacing it
! Party chat no longer displays colors when logged in server console
- Treefeller no longer lowers exp for big trees
- No longer supports 1.8 :(
- Removed plugin metrics
Version 1.5.03
= Fixed bug where absorption hearts could be attacked by allied players

View File

@@ -2,7 +2,9 @@
## The RPG lovers mod
### Builds
Currently, you can obtain our builds via the Spigot resource page: http://www.spigotmc.org/resources/mcmmo.2445/
Currently, you can obtain our builds via the Spigot resource page: https://www.spigotmc.org/resources/official-mcmmo.63489/
### Brief Description
The goal of mcMMO is to take core Minecraft game mechanics and expand them into add an extensive and quality RPG experience. Everything in mcMMO has been carefully thought out and is constantly being improved upon. Currently, mcMMO adds fourteen unique skills to train and level in. Each of these skills is highly customizable through our configuration files, allowing server admins to tweak mcMMO to best suit the needs of his or her server. Know that the mcMMO team is dedicated to providing an ever-evolving experience, and that we carefully read all feedback and bug reports in order to evaluate and balance the mechanics of mcMMO in every update.
@@ -11,29 +13,23 @@ The goal of mcMMO is to take core Minecraft game mechanics and expand them into
mcMMO is currently developed by a team of individuals from all over the world.
### Project Lead & Founder
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)](https://github.com/nossr50)
### Former Lead
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)](https://github.com/gmcferrin)
### Developers
[![gmcferrin](http://www.gravatar.com/avatar/b64c52daf25d206b27650788b5813b7b.png)]
(https://github.com/gmcferrin)
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)]
(https://github.com/bm01)
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)]
(https://github.com/Glitchfinder)
[![nossr50](http://www.gravatar.com/avatar/f2ee41eedfd645fb4a3a2c8f6cb1b18c.png)]
(https://github.com/nossr50)
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)]
(https://github.com/NuclearW)
[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)]
(https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)]
(https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)]
(https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)]
(https://github.com/riking)
[![bm01](http://www.gravatar.com/avatar/ec8146f5358177f12e9a252271bbc391.png)](https://github.com/bm01)
[![Glitchfinder](http://www.gravatar.com/avatar/5aa4cce22f72ae9c002ecec30f061d00.png)](https://github.com/Glitchfinder)
[![NuclearW](http://www.gravatar.com/avatar/90926bdcf1c8a75918df5ea5fa801ce6.png)](https://github.com/NuclearW)
[![shatteredbeam](http://www.gravatar.com/avatar/cad3b5d7d39cf5387afb87f494389610.png)](https://github.com/shatteredbeam)
[![TfT_02](http://www.gravatar.com/avatar/b8914f9970e1f6ffd5281ce4770e20a7.png)](https://github.com/TfT-02)
[![t00thpick1](http://www.gravatar.com/avatar/ee23c7794a0c40120c3474287c7bce06.png)](https://github.com/t00thpick1)
[![riking](https://1.gravatar.com/avatar/aca9f37e569ac3a63929920035a91ba4.png)](https://github.com/riking)
### Special thanks
[![EasyMFnE](https://www.gravatar.com/avatar/99c9a1fa3bbf957791ceac7b45daadb0.png)]
(https://github.com/EasyMFnE)
[![EasyMFnE](https://www.gravatar.com/avatar/99c9a1fa3bbf957791ceac7b45daadb0.png)](https://github.com/EasyMFnE)
Added the Alchemy skill
## Compiling
@@ -43,8 +39,7 @@ mcMMO uses Maven 3 to manage dependencies, packaging, and shading of necessary c
The typical command used to build mcMMO is: `mvn clean package install`
Required Libraries:
* JUnit
* EMetrics
* Bukkit
* JUnit
http://www.spigotmc.org/resources/mcmmo.2445/ for more up to date information.
https://www.spigotmc.org/resources/official-mcmmo.63489/ for more up to date information.

41
pom.xml
View File

@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>1.5.04-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<name>mcMMO</name>
<url>https://github.com/mcMMO-Dev/mcMMO</url>
<issueManagement>
@@ -53,8 +53,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.8</source>
<target>1.8</target>
<excludes>
</excludes>
</configuration>
@@ -79,21 +79,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>1.5</version>
<version>3.1.1</version>
<configuration>
<artifactSet>
<includes>
<include>com.turt2live.metrics:MetricsExtension</include>
<include>commons-logging:commons-logging</include>
<include>org.apache.tomcat:tomcat-jdbc</include>
<include>org.apache.tomcat:tomcat-juli</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>com.turt2live.metrics</pattern>
<shadedPattern>com.gmail.nossr50.metrics.mcstats</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.logging</pattern>
<shadedPattern>com.gmail.nossr50.commons.logging</shadedPattern>
@@ -126,22 +121,11 @@
</extension>
</extensions>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>Plugin MetricsExtension</id>
<url>http://repo.turt2live.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.8-R0.1-SNAPSHOT</version>
<type>jar</type>
<version>1.13.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -150,11 +134,6 @@
<version>4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.turt2live.metrics</groupId>
<artifactId>MetricsExtension</artifactId>
<version>0.0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-jdbc</artifactId>
@@ -162,17 +141,7 @@
<scope>compile</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>drtshock-releases</id>
<url>https://ci.drtshock.net/plugin/repository/everything/com/gmail/nossr50/mcMMO/</url>
</repository>
</distributionManagement>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<ciManagement>
<system>Jenkins</system>
<url>https://ci.drtshock.net/job/mcmmo/</url>
</ciManagement>
</project>

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.gmail.nossr50.mcMMO

View File

@@ -0,0 +1,46 @@
package com.gmail.nossr50.commands;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.database.FlatfileDatabaseManager;
import com.gmail.nossr50.database.SQLDatabaseManager;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
public class MHDCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (mcMMO.getDatabaseManager() instanceof SQLDatabaseManager) {
SQLDatabaseManager m = (SQLDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
if (mcMMO.getDatabaseManager() instanceof FlatfileDatabaseManager) {
FlatfileDatabaseManager m = (FlatfileDatabaseManager) mcMMO.getDatabaseManager();
m.resetMobHealthSettings();
for (McMMOPlayer player : UserManager.getPlayers()) {
player.getProfile().setMobHealthbarType(Config.getInstance().getMobHealthbarDefault());
}
sender.sendMessage("Mob health reset");
return true;
}
return false;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
return ImmutableList.of();
}
}

View File

@@ -27,7 +27,7 @@ public class McmmoCommand implements CommandExecutor {
if (Config.getInstance().getDonateMessageEnabled()) {
sender.sendMessage(LocaleLoader.getString("MOTD.Donate"));
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "tft_02@hotmail.com" + ChatColor.GOLD + " Paypal");
sender.sendMessage(ChatColor.GOLD + " - " + ChatColor.GREEN + "nossr50@gmail.com" + ChatColor.GOLD + " Paypal");
}
if (Permissions.showversion(sender)) {

View File

@@ -46,6 +46,12 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null;
}
if (skill != null && skill.isChildSkill())
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
editValues((Player) sender, UserManager.getPlayer(sender.getName()).getProfile(), skill, Integer.parseInt(args[1]));
return true;
@@ -65,6 +71,12 @@ public abstract class ExperienceCommand implements TabExecutor {
skill = null;
}
if (skill != null && skill.isChildSkill())
{
sender.sendMessage(LocaleLoader.getString("Commands.Skill.ChildSkill"));
return true;
}
int value = Integer.parseInt(args[2]);
String playerName = CommandUtils.getMatchedPlayerName(args[0]);

View File

@@ -1,8 +1,16 @@
package com.gmail.nossr50.commands.player;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
@@ -10,17 +18,8 @@ import org.bukkit.entity.Player;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.runnables.commands.MctopCommandAsyncTask;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
public class MctopCommand implements TabExecutor {
@Override
@@ -91,7 +90,12 @@ public class MctopCommand implements TabExecutor {
long cooldownMillis = Math.max(Config.getInstance().getDatabasePlayerCooldown(), 1750);
if (mcMMOPlayer.getDatabaseATS() + cooldownMillis > System.currentTimeMillis()) {
sender.sendMessage(LocaleLoader.getString("Commands.Database.Cooldown"));
double seconds = ((mcMMOPlayer.getDatabaseATS() + cooldownMillis) - System.currentTimeMillis()) / 1000;
if (seconds < 1) {
seconds = 1;
}
sender.sendMessage(LocaleLoader.formatString(LocaleLoader.getString("Commands.Database.Cooldown"), seconds));
return;
}

View File

@@ -1,16 +1,15 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class HerbalismCommand extends SkillCommand {
private String greenTerraLength;
@@ -87,8 +86,8 @@ public class HerbalismCommand extends SkillCommand {
protected void permissionsCheck(Player player) {
hasHylianLuck = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HYLIAN_LUCK);
canGreenTerra = Permissions.greenTerra(player);
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.CROPS) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.NETHER_WARTS) || Permissions.greenThumbPlant(player, Material.COCOA);
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLE_WALL) || Permissions.greenThumbBlock(player, Material.SMOOTH_BRICK);
canGreenThumbPlants = Permissions.greenThumbPlant(player, Material.WHEAT) || Permissions.greenThumbPlant(player, Material.CARROT) || Permissions.greenThumbPlant(player, Material.POTATO) || Permissions.greenThumbPlant(player, Material.BEETROOT) || Permissions.greenThumbPlant(player, Material.NETHER_WART) || Permissions.greenThumbPlant(player, Material.COCOA);
canGreenThumbBlocks = Permissions.greenThumbBlock(player, Material.DIRT) || Permissions.greenThumbBlock(player, Material.COBBLESTONE) || Permissions.greenThumbBlock(player, Material.COBBLESTONE_WALL) || Permissions.greenThumbBlock(player, Material.STONE_BRICKS);
canFarmersDiet = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET);
canDoubleDrop = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS) && !skill.getDoubleDropsDisabled();
canShroomThumb = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);

View File

@@ -1,16 +1,10 @@
package com.gmail.nossr50.commands.skills;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.ArcaneForging;
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
import com.gmail.nossr50.skills.repair.Repair;
@@ -18,6 +12,11 @@ import com.gmail.nossr50.skills.repair.RepairManager;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
public class RepairCommand extends SkillCommand {
private String repairMasteryBonus;
@@ -49,7 +48,7 @@ public class RepairCommand extends SkillCommand {
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
// We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);

View File

@@ -45,7 +45,7 @@ public class TamingCommand extends SkillCommand {
protected void permissionsCheck(Player player) {
canBeastLore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.BEAST_LORE);
canCallWild = Permissions.callOfTheWild(player, EntityType.HORSE) || Permissions.callOfTheWild(player, EntityType.WOLF) || Permissions.callOfTheWild(player, EntityType.OCELOT);
canEnvironmentallyAware = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ENVIROMENTALLY_AWARE);
canEnvironmentallyAware = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.ENVIRONMENTALLY_AWARE);
canFastFood = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FAST_FOOD);
canGore = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.GORE);
canSharpenedClaws = Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHARPENED_CLAWS);

View File

@@ -6,14 +6,13 @@ import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.metrics.MetricsManager;
public abstract class AutoUpdateConfigLoader extends ConfigLoader {
public AutoUpdateConfigLoader(String relativePath, String fileName) {
super(relativePath, fileName);
@@ -26,7 +25,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
@Override
protected void loadFile() {
super.loadFile();
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResource(fileName));
FileConfiguration internalConfig = YamlConfiguration.loadConfiguration(plugin.getResourceAsReader(fileName));
Set<String> configKeys = config.getKeys(true);
Set<String> internalConfigKeys = internalConfig.getKeys(true);
@@ -46,8 +45,8 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
}
for (String key : oldKeys) {
plugin.debug("Removing unused key: " + key);
config.set(key, null);
plugin.debug("Detected potentially unused key: " + key);
//config.set(key, null);
}
for (String key : newKeys) {
@@ -71,7 +70,7 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
try {
// Read internal
BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getResource(fileName)));
HashMap<String, String> comments = new HashMap<String, String>();
LinkedHashMap<String, String> comments = new LinkedHashMap<String, String>();
String temp = "";
String line;
@@ -82,6 +81,15 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
else if (line.contains(":")) {
line = line.substring(0, line.indexOf(":") + 1);
if (!temp.isEmpty()) {
if(comments.containsKey(line)) {
int index = 0;
while(comments.containsKey(line + index)) {
index++;
}
line = line + index;
}
comments.put(line, temp);
temp = "";
}
@@ -89,9 +97,20 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
}
// Dump to the new one
HashMap<String, Integer> indexed = new HashMap<String, Integer>();
for (String key : comments.keySet()) {
if (output.contains(key)) {
output = output.substring(0, output.indexOf(key)) + comments.get(key) + output.substring(output.indexOf(key));
String actualkey = key.substring(0, key.indexOf(":") + 1);
int index = 0;
if(indexed.containsKey(actualkey)) {
index = indexed.get(actualkey);
}
boolean isAtTop = !output.contains("\n" + actualkey);
index = output.indexOf((isAtTop ? "" : "\n") + actualkey, index);
if (index >= 0) {
output = output.substring(0, index) + "\n" + comments.get(key) + output.substring(isAtTop ? index : index + 1);
indexed.put(actualkey, index + comments.get(key).length() + actualkey.length() + 1);
}
}
}
@@ -116,13 +135,5 @@ public abstract class AutoUpdateConfigLoader extends ConfigLoader {
e.printStackTrace();
}
}
else {
for (String key : configKeys) {
if (!config.isConfigurationSection(key) && !config.get(key).equals(internalConfig.get(key))) {
MetricsManager.customConfig();
break;
}
}
}
}
}

View File

@@ -1,20 +1,19 @@
package com.gmail.nossr50.config;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.database.SQLDatabaseManager.PoolIdentifier;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class Config extends AutoUpdateConfigLoader {
private static Config instance;
@@ -178,6 +177,10 @@ public class Config extends AutoUpdateConfigLoader {
reason.add("Abilities.Limits.Tree_Feller_Threshold should be greater than 0!");
}
if (getFishingLureModifier() < 0) {
reason.add("Abilities.Fishing.Lure_Modifier should be at least 0!");
}
if (getDetonatorItem() == null) {
reason.add("Skills.Mining.Detonator_Item is invalid!");
}
@@ -265,6 +268,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getLevelUpSoundsEnabled() { return config.getBoolean("General.LevelUp_Sounds", true); }
public boolean getRefreshChunksEnabled() { return config.getBoolean("General.Refresh_Chunks", false); }
public boolean getMobHealthbarEnabled() { return config.getBoolean("Mob_Healthbar.Enabled", true); }
/* Mob Healthbar */
public MobHealthbarType getMobHealthbarDefault() {
try {
@@ -451,6 +456,8 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getDoubleDropsDisabled(SkillType skill) {
String skillName = StringUtils.getCapitalized(skill.toString());
ConfigurationSection section = config.getConfigurationSection("Double_Drops." + skillName);
if (section == null)
return false;
Set<String> keys = section.getKeys(false);
boolean disabled = true;
@@ -477,6 +484,7 @@ public class Config extends AutoUpdateConfigLoader {
public boolean getFishingDropsEnabled() { return config.getBoolean("Skills.Fishing.Drops_Enabled", true); }
public boolean getFishingOverrideTreasures() { return config.getBoolean("Skills.Fishing.Override_Vanilla_Treasures", true); }
public boolean getFishingExtraFish() { return config.getBoolean("Skills.Fishing.Extra_Fish", true); }
public double getFishingLureModifier() { return config.getDouble("Skills.Fishing.Lure_Modifier", 4.0D); }
/* Mining */
public Material getDetonatorItem() { return Material.matchMaterial(config.getString("Skills.Mining.Detonator_Name", "FLINT_AND_STEEL")); }
@@ -509,7 +517,7 @@ public class Config extends AutoUpdateConfigLoader {
public double getTamingCOTWRange() { return config.getDouble("Skills.Taming.Call_Of_The_Wild.Range", 40.0D); }
/* Woodcutting */
public boolean getWoodcuttingDoubleDropsEnabled(TreeSpecies species) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
public boolean getWoodcuttingDoubleDropsEnabled(BlockData material) { return config.getBoolean("Double_Drops.Woodcutting." + StringUtils.getFriendlyConfigBlockDataString(material)); }
public boolean getTreeFellerSoundsEnabled() { return config.getBoolean("Skills.Woodcutting.Tree_Feller_Sounds", true); }
/* AFK Leveling */
@@ -533,4 +541,6 @@ public class Config extends AutoUpdateConfigLoader {
/* 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); }
public float getMasterVolume() { return (float) config.getDouble("Sounds.MasterVolume", 1.0); }
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.config;
import java.io.InputStreamReader;
import org.bukkit.configuration.file.YamlConfiguration;
import com.gmail.nossr50.mcMMO;
@@ -29,8 +31,9 @@ public class HiddenConfig {
}
public void load() {
if (mcMMO.p.getResource(fileName) != null) {
config = YamlConfiguration.loadConfiguration(mcMMO.p.getResource(fileName));
InputStreamReader reader = mcMMO.p.getResourceAsReader(fileName);
if (reader != null) {
config = YamlConfiguration.loadConfiguration(reader);
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);

View File

@@ -1,21 +1,17 @@
package com.gmail.nossr50.config.experience;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.GrassSpecies;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.entity.EntityType;
import org.bukkit.material.LongGrass;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.AutoUpdateConfigLoader;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.MaterialType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.alchemy.PotionStage;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
import java.util.ArrayList;
import java.util.List;
public class ExperienceConfig extends AutoUpdateConfigLoader {
private static ExperienceConfig instance;
@@ -103,10 +99,6 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
reason.add("Experience.Combat.Multiplier.Animals should be at least 0!");
}
if (getWitherSkeletonXP() < 0) {
reason.add("Experience.Combat.Multiplier.Wither_Skeleton should be at least 0!");
}
if (getDodgeXPModifier() < 0) {
reason.add("Skills.Acrobatics.Dodge_XP_Modifier should be at least 0!");
}
@@ -132,31 +124,14 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
}
/* Taming */
if (getTamingXPWolf() <= 0) {
if (getTamingXP(EntityType.WOLF) <= 0) {
reason.add("Experience.Taming.Animal_Taming.Wolf should be greater than 0!");
}
if (getTamingXPOcelot() <= 0) {
if (getTamingXP(EntityType.OCELOT) <= 0) {
reason.add("Experience.Taming.Animal_Taming.Ocelot should be greater than 0!");
}
/* Woodcutting */
for (TreeSpecies species : TreeSpecies.values()) {
String key = "Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_");
if (config.getInt(key) <= 0) {
reason.add(key + " should be greater than 0!");
}
}
if (getWoodcuttingXPHugeBrownMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Brown should be greater than 0!");
}
if (getWoodcuttingXPHugeRedMushroom() <= 0) {
reason.add("Experience.Woodcutting.Huge_Mushroom_Red should be greater than 0!");
}
return noErrorsInConfig(reason);
}
@@ -207,12 +182,67 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Combat XP Multipliers */
public double getCombatXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
public double getAnimalsXP(EntityType entity) { return config.getDouble("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_"), getAnimalsXP()); }
public double getAnimalsXP() { return config.getDouble("Experience.Combat.Multiplier.Animals", 1.0); }
public double getWitherSkeletonXP() { return config.getDouble("Experience.Combat.Multiplier.Wither_Skeleton", 4.0); }
public double getElderGuardianXP() { return config.getDouble("Experience.Combat.Multiplier.Elder_Guardian", 4.0); }
public boolean hasCombatXP(EntityType entity) {return config.contains("Experience.Combat.Multiplier." + StringUtils.getPrettyEntityTypeString(entity).replace(" ", "_")); }
/* Materials */
public int getXp(SkillType skill, Material material) { return config.getInt("Experience." + StringUtils.getCapitalized(skill.toString()) + "." + StringUtils.getPrettyItemString(material).replace(" ", "_")); }
public int getXp(SkillType skill, Material data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
/* Materials */
public int getXp(SkillType skill, BlockData data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return config.getInt(explicitString);
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return config.getInt(friendlyString);
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
if (config.contains(wildcardString))
return config.getInt(wildcardString);
return 0;
}
public boolean isSkillBlock(SkillType skill, Material data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigMaterialString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigMaterialString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigMaterialString(data);
return config.contains(wildcardString);
}
public boolean isSkillBlock(SkillType skill, BlockData data)
{
String baseString = "Experience." + StringUtils.getCapitalized(skill.toString()) + ".";
String explicitString = baseString + StringUtils.getExplicitConfigBlockDataString(data);
if (config.contains(explicitString))
return true;
String friendlyString = baseString + StringUtils.getFriendlyConfigBlockDataString(data);
if (config.contains(friendlyString))
return true;
String wildcardString = baseString + StringUtils.getWildcardConfigBlockDataString(data);
return config.contains(wildcardString);
}
/* Acrobatics */
public int getDodgeXPModifier() { return config.getInt("Experience.Acrobatics.Dodge", 120); }
@@ -227,161 +257,15 @@ public class ExperienceConfig extends AutoUpdateConfigLoader {
/* Archery */
public double getArcheryDistanceMultiplier() { return config.getDouble("Experience.Archery.Distance_Multiplier", 0.025); }
/* Excavation */
public int getDirtAndSandXp(MaterialData data) {
Material type = data.getItemType();
if (type == Material.DIRT) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Excavation.Dirt", 40);
case 0x1:
return config.getInt("Experience.Excavation.Coarse_Dirt", 40);
case 0x2:
return config.getInt("Experience.Excavation.Podzol", 40);
default:
return 0;
}
}
else if (type == Material.SAND) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Excavation.Sand", 40);
case 0x1:
return config.getInt("Experience.Excavation.Red_Sand", 40);
default:
return 0;
}
}
return 0;
}
/* Fishing */
public int getFishXp(MaterialData data) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Fishing.Raw_Fish", 800);
case 0x1:
return config.getInt("Experience.Fishing.Raw_Salmon", 800);
case 0x2:
return config.getInt("Experience.Fishing.Clownfish", 800);
case 0x3:
return config.getInt("Experience.Fishing.Pufferfish", 800);
default:
return 0;
}
}
public int getFishingShakeXP() { return config.getInt("Experience.Fishing.Shake", 50); }
/* Herbalism */
public int getFlowerAndGrassXp(MaterialData data) {
Material type = data.getItemType();
if (type == Material.RED_ROSE) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Herbalism.Poppy", 100);
case 0x1:
return config.getInt("Experience.Herbalism.Blue_Orchid", 150);
case 0x2:
return config.getInt("Experience.Herbalism.Allium", 300);
case 0x3:
return config.getInt("Experience.Herbalism.Azure_Bluet", 150);
case 0x4:
return config.getInt("Experience.Herbalism.Red_Tulip", 150);
case 0x5:
return config.getInt("Experience.Herbalism.Orange_Tulip", 150);
case 0x6:
return config.getInt("Experience.Herbalism.White_Tulip", 150);
case 0x7:
return config.getInt("Experience.Herbalism.Pink_Tulip", 150);
case 0x8:
return config.getInt("Experience.Herbalism.Oxeye_Daisy", 150);
default:
return 0;
}
}
else if (type == Material.LONG_GRASS) {
GrassSpecies species = ((LongGrass) data).getSpecies();
if (species == null) {
return 0;
}
switch (species) {
case DEAD:
return config.getInt("Experience.Herbalism.Dead_Bush", 30);
case FERN_LIKE:
return config.getInt("Experience.Herbalism.Small_Fern", 10);
case NORMAL:
return config.getInt("Experience.Herbalism.Small_Grass", 10);
default:
return 0;
}
}
else if (type == Material.DOUBLE_PLANT) {
switch (data.getData()) {
case 0x0:
return config.getInt("Experience.Herbalism.Sunflower", 50);
case 0x1:
return config.getInt("Experience.Herbalism.Lilac", 50);
case 0x2:
return config.getInt("Experience.Herbalism.Tall_Grass", 50);
case 0x3:
return config.getInt("Experience.Herbalism.Tall_Fern", 50);
case 0x4:
return config.getInt("Experience.Herbalism.Rose_Bush", 50);
case 0x5:
return config.getInt("Experience.Herbalism.Peony", 50);
default:
return 0;
}
}
return 0;
}
/* Repair */
public double getRepairXPBase() { return config.getDouble("Experience.Repair.Base", 1000.0); }
public double getRepairXP(MaterialType repairMaterialType) { return config.getDouble("Experience.Repair." + StringUtils.getCapitalized(repairMaterialType.toString())); }
/* Taming */
public int getTamingXPHorse() { return config.getInt("Experience.Taming.Animal_Taming.Horse", 1000); }
public int getTamingXPWolf() { return config.getInt("Experience.Taming.Animal_Taming.Wolf", 250); }
public int getTamingXPOcelot() { return config.getInt("Experience.Taming.Animal_Taming.Ocelot", 500); }
/* Woodcutting */
public int getWoodcuttingTreeXP(TreeSpecies species) { return config.getInt("Experience.Woodcutting." + StringUtils.getPrettyTreeSpeciesString(species).replace(" ", "_")); }
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 int getTamingXP(EntityType type)
{
return config.getInt("Experience.Taming.Animal_Taming." + StringUtils.getPrettyEntityTypeString(type));
}
}

View File

@@ -1,29 +1,27 @@
package com.gmail.nossr50.config.mods;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
public class CustomBlockConfig extends ConfigLoader {
private boolean needsUpdate = false;
public List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
public List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
public List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
public List<MaterialData> customOres = new ArrayList<MaterialData>();
public List<MaterialData> customLogs = new ArrayList<MaterialData>();
public List<MaterialData> customLeaves = new ArrayList<MaterialData>();
public List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
public List<Material> customExcavationBlocks = new ArrayList<>();
public List<Material> customHerbalismBlocks = new ArrayList<>();
public List<Material> customMiningBlocks = new ArrayList<>();
public List<Material> customOres = new ArrayList<>();
public List<Material> customLogs = new ArrayList<>();
public List<Material> customLeaves = new ArrayList<>();
public List<Material> customAbilityBlocks = new ArrayList<>();
public HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
public HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
protected CustomBlockConfig(String fileName) {
super("mods", fileName);
@@ -44,7 +42,7 @@ public class CustomBlockConfig extends ConfigLoader {
}
}
private void loadBlocks(String skillType, List<MaterialData> blockList) {
private void loadBlocks(String skillType, List<Material> blockList) {
if (needsUpdate) {
return;
}
@@ -58,7 +56,7 @@ public class CustomBlockConfig extends ConfigLoader {
Set<String> skillConfigSet = skillSection.getKeys(false);
for (String blockName : skillConfigSet) {
if (config.contains(skillType + "." + blockName + "." + ".Drop_Item")) {
if (config.contains(skillType + "." + blockName + ".Drop_Item")) {
needsUpdate = true;
return;
}
@@ -72,11 +70,8 @@ public class CustomBlockConfig extends ConfigLoader {
continue;
}
byte blockData = (blockInfo.length == 2) ? Byte.valueOf(blockInfo[1]) : 0;
MaterialData blockMaterialData = new MaterialData(blockMaterial, blockData);
if (blockList != null) {
blockList.add(blockMaterialData);
blockList.add(blockMaterial);
}
if (skillType.equals("Ability_Blocks")) {
@@ -87,20 +82,20 @@ public class CustomBlockConfig extends ConfigLoader {
int smeltingXp = 0;
if (skillType.equals("Mining") && config.getBoolean(skillType + "." + blockName + ".Is_Ore")) {
customOres.add(blockMaterialData);
customOres.add(blockMaterial);
smeltingXp = config.getInt(skillType + "." + blockName + ".Smelting_XP_Gain", xp / 10);
}
else if (skillType.equals("Woodcutting")) {
if (config.getBoolean(skillType + "." + blockName + ".Is_Log")) {
customLogs.add(blockMaterialData);
customLogs.add(blockMaterial);
}
else {
customLeaves.add(blockMaterialData);
customLeaves.add(blockMaterial);
xp = 0; // Leaves don't grant XP
}
}
customBlockMap.put(blockMaterialData, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
customBlockMap.put(blockMaterial, new CustomBlock(xp, config.getBoolean(skillType + "." + blockName + ".Double_Drops_Enabled"), smeltingXp));
}
}
}

View File

@@ -3,7 +3,7 @@ package com.gmail.nossr50.config.mods;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.material.MaterialData;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
@@ -54,7 +54,7 @@ public class CustomEntityConfig extends ConfigLoader {
canBeSummoned = false;
}
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new MaterialData(callOfTheWildMaterial, callOfTheWildData).toItemStack(1) : null), callOfTheWildAmount);
CustomEntity entity = new CustomEntity(xpMultiplier, canBeTamed, tamingXp, canBeSummoned, (canBeSummoned ? new ItemStack(callOfTheWildMaterial) : null), callOfTheWildAmount);
customEntityTypeMap.put(entityTypeName, entity);
customEntityClassMap.put(clazz == null ? null : clazz.getName(), entity);

View File

@@ -6,11 +6,15 @@ import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.ConfigLoader;
@@ -28,7 +32,7 @@ public class PotionConfig extends ConfigLoader {
private List<ItemStack> concoctionsIngredientsTierSeven = new ArrayList<ItemStack>();
private List<ItemStack> concoctionsIngredientsTierEight = new ArrayList<ItemStack>();
private Map<Short, AlchemyPotion> potionMap = new HashMap<Short, AlchemyPotion>();
private Map<String, AlchemyPotion> potionMap = new HashMap<String, AlchemyPotion>();
private PotionConfig() {
super("potions.yml");
@@ -90,11 +94,11 @@ public class PotionConfig extends ConfigLoader {
int pass = 0;
int fail = 0;
for (String dataValue : potionSection.getKeys(false)) {
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(dataValue));
for (String potionName : potionSection.getKeys(false)) {
AlchemyPotion potion = loadPotion(potionSection.getConfigurationSection(potionName));
if (potion != null) {
potionMap.put(potion.getDataValue(), potion);
potionMap.put(potionName, potion);
pass++;
}
else {
@@ -115,12 +119,28 @@ public class PotionConfig extends ConfigLoader {
*/
private AlchemyPotion loadPotion(ConfigurationSection potion_section) {
try {
short dataValue = Short.parseShort(potion_section.getName());
String name = potion_section.getString("Name");
if (name != null) {
name = ChatColor.translateAlternateColorCodes('&', name);
}
PotionData data;
if (!potion_section.contains("PotionData")) { // Backwards config compatability
short dataValue = Short.parseShort(potion_section.getName());
Potion potion = Potion.fromDamage(dataValue);
data = new PotionData(potion.getType(), potion.hasExtendedDuration(), potion.getLevel() == 2);
} else {
ConfigurationSection potionData = potion_section.getConfigurationSection("PotionData");
data = new PotionData(PotionType.valueOf(potionData.getString("PotionType", "WATER")), potionData.getBoolean("Extended", false), potionData.getBoolean("Upgraded", false));
}
Material material = Material.POTION;
String mat = potion_section.getString("Material", null);
if (mat != null) {
material = Material.valueOf(mat);
}
List<String> lore = new ArrayList<String>();
if (potion_section.contains("Lore")) {
@@ -146,13 +166,21 @@ public class PotionConfig extends ConfigLoader {
}
}
}
Color color = null;
if (potion_section.contains("Color")) {
color = Color.fromRGB(potion_section.getInt("Color"));
}
else {
color = this.generateColor(effects);
}
Map<ItemStack, Short> children = new HashMap<ItemStack, Short>();
Map<ItemStack, String> children = new HashMap<ItemStack, String>();
if (potion_section.contains("Children")) {
for (String child : potion_section.getConfigurationSection("Children").getKeys(false)) {
ItemStack ingredient = loadIngredient(child);
if (ingredient != null) {
children.put(ingredient, Short.parseShort(potion_section.getConfigurationSection("Children").getString(child)));
children.put(ingredient, potion_section.getConfigurationSection("Children").getString(child));
}
else {
mcMMO.p.getLogger().warning("Failed to parse child for potion " + name + ": " + child);
@@ -160,7 +188,7 @@ public class PotionConfig extends ConfigLoader {
}
}
return new AlchemyPotion(dataValue, name, lore, effects, children);
return new AlchemyPotion(material, data, name, lore, effects, color, children);
}
catch (Exception e) {
mcMMO.p.getLogger().warning("Failed to load Alchemy potion: " + potion_section.getName());
@@ -182,13 +210,10 @@ public class PotionConfig extends ConfigLoader {
return null;
}
String[] parts = ingredient.split(":");
Material material = parts.length > 0 ? Material.getMaterial(parts[0]) : null;
short data = parts.length > 1 ? Short.parseShort(parts[1]) : 0;
Material material = Material.getMaterial(ingredient);
if (material != null) {
return new ItemStack(material, 1, data);
return new ItemStack(material, 1);
}
return null;
@@ -217,10 +242,51 @@ public class PotionConfig extends ConfigLoader {
}
public boolean isValidPotion(ItemStack item) {
return potionMap.containsKey(item.getDurability());
return getPotion(item) != null;
}
public AlchemyPotion getPotion(short durability) {
return potionMap.get(durability);
public AlchemyPotion getPotion(String name) {
return potionMap.get(name);
}
public AlchemyPotion getPotion(ItemStack item) {
for (AlchemyPotion potion : potionMap.values()) {
if (potion.isSimilar(item)) {
return potion;
}
}
return null;
}
public Color generateColor(List<PotionEffect> effects) {
if (effects != null && !effects.isEmpty()) {
List<Color> colors = new ArrayList<Color>();
for (PotionEffect effect : effects) {
if (effect.getType().getColor() != null) {
colors.add(effect.getType().getColor());
}
}
if (!colors.isEmpty()) {
if (colors.size() > 1) {
return calculateAverageColor(colors);
}
return colors.get(0);
}
}
return null;
}
public Color calculateAverageColor(List<Color> colors) {
int red = 0;
int green = 0;
int blue = 0;
for (Color color : colors) {
red += color.getRed();
green += color.getGreen();
blue += color.getBlue();
}
Color color = Color.fromRGB(red/colors.size(), green/colors.size(), blue/colors.size());
return color;
}
}

View File

@@ -1,72 +1,36 @@
package com.gmail.nossr50.config.treasure;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.treasure.*;
import com.gmail.nossr50.util.EnchantmentUtils;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.TreeSpecies;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
import org.bukkit.potion.Potion;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionType;
import com.gmail.nossr50.config.ConfigLoader;
import com.gmail.nossr50.datatypes.treasure.EnchantmentTreasure;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.datatypes.treasure.FishingTreasure;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.datatypes.treasure.Rarity;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.util.EnchantmentUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class TreasureConfig extends ConfigLoader {
private static TreasureConfig instance;
public List<ExcavationTreasure> excavationFromDirt = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGrass = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromGravel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromClay = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromMycel = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSoulSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromSnow = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromRedSand = new ArrayList<ExcavationTreasure>();
public List<ExcavationTreasure> excavationFromPodzol = new ArrayList<ExcavationTreasure>();
public HashMap<String, List<ExcavationTreasure>> excavationMap = new HashMap<String, List<ExcavationTreasure>>();
public List<HylianTreasure> hylianFromBushes = new ArrayList<HylianTreasure>();
public List<HylianTreasure> hylianFromFlowers = new ArrayList<HylianTreasure>();
public List<HylianTreasure> hylianFromPots = new ArrayList<HylianTreasure>();
public HashMap<EntityType, List<ShakeTreasure>> shakeMap = new HashMap<EntityType, List<ShakeTreasure>>();
public HashMap<String, List<HylianTreasure>> hylianMap = new HashMap<String, List<HylianTreasure>>();
public List<ShakeTreasure> shakeFromBlaze = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromCaveSpider = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSpider = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromChicken = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromCow = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromCreeper = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromEnderman = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromGhast = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromHorse = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromIronGolem = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMagmaCube = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromMushroomCow = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromPig = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromPigZombie = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromPlayer = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSheep = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSkeleton = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSlime = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSnowman = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromSquid = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromWitch = new ArrayList<ShakeTreasure>();
public List<ShakeTreasure> shakeFromZombie = new ArrayList<ShakeTreasure>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<FishingTreasure>> fishingRewards = new HashMap<Rarity, List<FishingTreasure>>();
public HashMap<Rarity, List<EnchantmentTreasure>> fishingEnchantments = new HashMap<Rarity, List<EnchantmentTreasure>>();
private TreasureConfig() {
@@ -87,7 +51,6 @@ public class TreasureConfig extends ConfigLoader {
protected boolean validateKeys() {
// Validate all the settings!
List<String> reason = new ArrayList<String>();
for (String tier : config.getConfigurationSection("Enchantment_Drop_Rates").getKeys(false)) {
double totalEnchantDropRate = 0;
double totalItemDropRate = 0;
@@ -127,19 +90,19 @@ public class TreasureConfig extends ConfigLoader {
return;
}
loadTreaures("Fishing");
loadTreaures("Excavation");
loadTreaures("Hylian_Luck");
loadTreasures("Fishing");
loadTreasures("Excavation");
loadTreasures("Hylian_Luck");
loadEnchantments();
for (EntityType entity : EntityType.values()) {
if (entity.isAlive()) {
loadTreaures("Shake." + entity.toString());
loadTreasures("Shake." + entity.toString());
}
}
}
private void loadTreaures(String type) {
private void loadTreasures(String type) {
boolean isFishing = type.equals("Fishing");
boolean isShake = type.contains("Shake");
boolean isExcavation = type.equals("Excavation");
@@ -170,18 +133,13 @@ public class TreasureConfig extends ConfigLoader {
*/
Material material;
if (materialName.contains("POTION")) {
material = Material.POTION;
}
else if (materialName.contains("INK_SACK")) {
material = Material.INK_SACK;
}
else if (materialName.contains("INVENTORY")) {
// Use magic material BED_BLOCK to know that we're grabbing something from the inventory and not a normal treasure
shakeFromPlayer.add(new ShakeTreasure(new ItemStack(Material.BED_BLOCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
if (materialName.contains("INVENTORY")) {
// Use magic material BEDROCK to know that we're grabbing something from the inventory and not a normal treasure
if (!shakeMap.containsKey(EntityType.PLAYER))
shakeMap.put(EntityType.PLAYER, new ArrayList<ShakeTreasure>());
shakeMap.get(EntityType.PLAYER).add(new ShakeTreasure(new ItemStack(Material.BEDROCK, 1, (byte) 0), 1, getInventoryStealDropChance(), getInventoryStealDropLevel()));
continue;
}
else {
} else {
material = Material.matchMaterial(materialName);
}
@@ -239,61 +197,37 @@ public class TreasureConfig extends ConfigLoader {
ItemStack item = null;
if (materialName.contains("POTION")) {
String potionType = materialName.substring(7);
Material mat = Material.matchMaterial(materialName);
if (mat == null) {
reason.add("Potion format for Treasures.yml has changed");
} else {
item = new ItemStack(mat, amount, data);
PotionMeta itemMeta = (PotionMeta) item.getItemMeta();
try {
item = new Potion(PotionType.valueOf(potionType.toUpperCase().trim())).toItemStack(amount);
PotionType potionType = null;
try {
potionType = PotionType.valueOf(config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
} catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + config.getString(type + "." + treasureName + ".PotionData.PotionType", "WATER"));
}
boolean extended = config.getBoolean(type + "." + treasureName + ".PotionData.Extended", false);
boolean upgraded = config.getBoolean(type + "." + treasureName + ".PotionData.Upgraded", false);
itemMeta.setBasePotionData(new PotionData(potionType, extended, upgraded));
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
item.setItemMeta(itemMeta);
}
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
List<String> lore = new ArrayList<String>();
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
}
item.setItemMeta(itemMeta);
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Potion_Type: " + potionType);
}
}
else if (materialName.contains("INK_SACK")) {
String color = materialName.substring(9);
try {
Dye dye = new Dye();
dye.setColor(DyeColor.valueOf(color.toUpperCase().trim()));
item = dye.toItemStack(amount);
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
ItemMeta itemMeta = item.getItemMeta();
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', config.getString(type + "." + treasureName + ".Custom_Name")));
item.setItemMeta(itemMeta);
}
if (config.contains(type + "." + treasureName + ".Lore")) {
ItemMeta itemMeta = item.getItemMeta();
List<String> lore = new ArrayList<String>();
for (String s : config.getStringList(type + "." + treasureName + ".Lore")) {
lore.add(ChatColor.translateAlternateColorCodes('&', s));
}
itemMeta.setLore(lore);
item.setItemMeta(itemMeta);
}
}
catch (IllegalArgumentException ex) {
reason.add("Invalid Dye_Color: " + color);
}
}
else if (material != null) {
} else if (material != null) {
item = new ItemStack(material, amount, data);
if (config.contains(type + "." + treasureName + ".Custom_Name")) {
@@ -316,141 +250,66 @@ public class TreasureConfig extends ConfigLoader {
if (noErrorsInConfig(reason)) {
if (isFishing) {
fishingRewards.get(rarity).add(new FishingTreasure(item, xp));
}
else if (isShake) {
} else if (isShake) {
ShakeTreasure shakeTreasure = new ShakeTreasure(item, xp, dropChance, dropLevel);
if (type.equals("Shake.BLAZE")) {
shakeFromBlaze.add(shakeTreasure);
}
else if (type.equals("Shake.CAVE_SPIDER")) {
shakeFromCaveSpider.add(shakeTreasure);
}
else if (type.equals("Shake.CHICKEN")) {
shakeFromChicken.add(shakeTreasure);
}
else if (type.equals("Shake.COW")) {
shakeFromCow.add(shakeTreasure);
}
else if (type.equals("Shake.CREEPER")) {
shakeFromCreeper.add(shakeTreasure);
}
else if (type.equals("Shake.ENDERMAN")) {
shakeFromEnderman.add(shakeTreasure);
}
else if (type.equals("Shake.GHAST")) {
shakeFromGhast.add(shakeTreasure);
}
else if (type.equals("Shake.HORSE")) {
shakeFromHorse.add(shakeTreasure);
}
else if (type.equals("Shake.IRON_GOLEM")) {
shakeFromIronGolem.add(shakeTreasure);
}
else if (type.equals("Shake.MAGMA_CUBE")) {
shakeFromMagmaCube.add(shakeTreasure);
}
else if (type.equals("Shake.MUSHROOM_COW")) {
shakeFromMushroomCow.add(shakeTreasure);
}
else if (type.equals("Shake.PIG")) {
shakeFromPig.add(shakeTreasure);
}
else if (type.equals("Shake.PIG_ZOMBIE")) {
shakeFromPigZombie.add(shakeTreasure);
}
else if (type.equals("Shake.PLAYER")) {
shakeFromPlayer.add(shakeTreasure);
}
else if (type.equals("Shake.SHEEP")) {
shakeFromSheep.add(shakeTreasure);
}
else if (type.equals("Shake.SKELETON")) {
shakeFromSkeleton.add(shakeTreasure);
}
else if (type.equals("Shake.SLIME")) {
shakeFromSlime.add(shakeTreasure);
}
else if (type.equals("Shake.SPIDER")) {
shakeFromSpider.add(shakeTreasure);
}
else if (type.equals("Shake.SNOWMAN")) {
shakeFromSnowman.add(shakeTreasure);
}
else if (type.equals("Shake.SQUID")) {
shakeFromSquid.add(shakeTreasure);
}
else if (type.equals("Shake.WITCH")) {
shakeFromWitch.add(shakeTreasure);
}
else if (type.equals("Shake.ZOMBIE")) {
shakeFromZombie.add(shakeTreasure);
}
}
else if (isExcavation) {
EntityType entityType = EntityType.valueOf(type.substring(6));
if (!shakeMap.containsKey(entityType))
shakeMap.put(entityType, new ArrayList<ShakeTreasure>());
shakeMap.get(entityType).add(shakeTreasure);
} else if (isExcavation) {
ExcavationTreasure excavationTreasure = new ExcavationTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
if (dropList.contains("Dirt")) {
excavationFromDirt.add(excavationTreasure);
for (String blockType : dropList) {
if (!excavationMap.containsKey(blockType))
excavationMap.put(blockType, new ArrayList<ExcavationTreasure>());
excavationMap.get(blockType).add(excavationTreasure);
}
if (dropList.contains("Grass")) {
excavationFromGrass.add(excavationTreasure);
}
if (dropList.contains("Sand")) {
excavationFromSand.add(excavationTreasure);
}
if (dropList.contains("Gravel")) {
excavationFromGravel.add(excavationTreasure);
}
if (dropList.contains("Clay")) {
excavationFromClay.add(excavationTreasure);
}
if (dropList.contains("Mycelium")) {
excavationFromMycel.add(excavationTreasure);
}
if (dropList.contains("Soul_Sand")) {
excavationFromSoulSand.add(excavationTreasure);
}
if (dropList.contains("Snow")) {
excavationFromSnow.add(excavationTreasure);
}
if (dropList.contains("Red_Sand")) {
excavationFromRedSand.add(excavationTreasure);
}
if (dropList.contains("Podzol")) {
excavationFromPodzol.add(excavationTreasure);
}
}
else if (isHylian) {
} else if (isHylian) {
HylianTreasure hylianTreasure = new HylianTreasure(item, xp, dropChance, dropLevel);
List<String> dropList = config.getStringList(type + "." + treasureName + ".Drops_From");
if (dropList.contains("Bushes")) {
hylianFromBushes.add(hylianTreasure);
}
for (String dropper : dropList) {
if (dropper.equals("Bushes")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.FERN), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.TALL_GRASS), hylianTreasure);
for (Material species : Tag.SAPLINGS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
if (dropList.contains("Flowers")) {
hylianFromFlowers.add(hylianTreasure);
}
if (dropList.contains("Pots")) {
hylianFromPots.add(hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DEAD_BUSH), hylianTreasure);
continue;
}
if (dropper.equals("Flowers")) {
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.POPPY), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.DANDELION), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.BLUE_ORCHID), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ALLIUM), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.AZURE_BLUET), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.ORANGE_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.PINK_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.RED_TULIP), hylianTreasure);
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(Material.WHITE_TULIP), hylianTreasure);
continue;
}
if (dropper.equals("Pots")) {
for (Material species : Tag.FLOWER_POTS.getValues())
AddHylianTreasure(StringUtils.getFriendlyConfigMaterialString(species), hylianTreasure);
continue;
}
AddHylianTreasure(dropper, hylianTreasure);
}
}
}
}
}
private void AddHylianTreasure(String dropper, HylianTreasure treasure) {
if (!hylianMap.containsKey(dropper))
hylianMap.put(dropper, new ArrayList<HylianTreasure>());
hylianMap.get(dropper).add(treasure);
}
private void loadEnchantments() {
for (Rarity rarity : Rarity.values()) {
if (rarity == Rarity.TRAP || rarity == Rarity.RECORD) {
@@ -481,11 +340,27 @@ public class TreasureConfig extends ConfigLoader {
}
}
public boolean getInventoryStealEnabled() { return config.contains("Shake.PLAYER.INVENTORY"); }
public boolean getInventoryStealStacks() { return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks"); }
public double getInventoryStealDropChance() { return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance"); }
public int getInventoryStealDropLevel() { return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level"); }
public boolean getInventoryStealEnabled() {
return config.contains("Shake.PLAYER.INVENTORY");
}
public double getItemDropRate(int tier, Rarity rarity) { return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
public double getEnchantmentDropRate(int tier, Rarity rarity) { return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString()); }
public boolean getInventoryStealStacks() {
return config.getBoolean("Shake.PLAYER.INVENTORY.Whole_Stacks");
}
public double getInventoryStealDropChance() {
return config.getDouble("Shake.PLAYER.INVENTORY.Drop_Chance");
}
public int getInventoryStealDropLevel() {
return config.getInt("Shake.PLAYER.INVENTORY.Drop_Level");
}
public double getItemDropRate(int tier, Rarity rarity) {
return config.getDouble("Item_Drop_Rates.Tier_" + tier + "." + rarity.toString());
}
public double getEnchantmentDropRate(int tier, Rarity rarity) {
return config.getDouble("Enchantment_Drop_Rates.Tier_" + tier + "." + rarity.toString());
}
}

View File

@@ -1289,4 +1289,57 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
public static int EXP_ALCHEMY = 40;
public static int UUID_INDEX = 41;
public static int SCOREBOARD_TIPS = 42;
public void resetMobHealthSettings() {
BufferedReader in = null;
FileWriter out = null;
String usersFilePath = mcMMO.getUsersFilePath();
synchronized (fileWritingLock) {
try {
in = new BufferedReader(new FileReader(usersFilePath));
StringBuilder writer = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
// Remove empty lines from the file
if (line.isEmpty()) {
continue;
}
String[] character = line.split(":");
character[HEALTHBAR] = Config.getInstance().getMobHealthbarDefault().toString();
line = new StringBuilder(org.apache.commons.lang.StringUtils.join(character, ":")).append(":").toString();
writer.append(line).append("\r\n");
}
// Write the new file
out = new FileWriter(usersFilePath);
out.write(writer.toString());
}
catch (IOException e) {
mcMMO.p.getLogger().severe("Exception while reading " + usersFilePath + " (Are you sure you formatted it correctly?)" + e.toString());
}
finally {
if (in != null) {
try {
in.close();
}
catch (IOException e) {
// Ignore
}
}
if (out != null) {
try {
out.close();
}
catch (IOException e) {
// Ignore
}
}
}
}
}
}

View File

@@ -1,22 +1,5 @@
package com.gmail.nossr50.database;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
@@ -25,14 +8,19 @@ import com.gmail.nossr50.datatypes.database.UpgradeType;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.database.UUIDUpdateAsyncTask;
import com.gmail.nossr50.util.Misc;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.apache.tomcat.jdbc.pool.PoolProperties;
import org.bukkit.scheduler.BukkitRunnable;
import java.sql.*;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
public final class SQLDatabaseManager implements DatabaseManager {
private static final String ALL_QUERY_VERSION = "taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy";
private static final String ALL_QUERY_VERSION = "total";
private String tablePrefix = Config.getInstance().getMySQLTablePrefix();
private final Map<UUID, Integer> cachedUserIDs = new HashMap<UUID, Integer>();
@@ -237,7 +225,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ " taming = ?, mining = ?, repair = ?, woodcutting = ?"
+ ", unarmed = ?, herbalism = ?, excavation = ?"
+ ", archery = ?, swords = ?, axes = ?, acrobatics = ?"
+ ", fishing = ?, alchemy = ? WHERE user_id = ?");
+ ", fishing = ?, alchemy = ?, total = ? WHERE user_id = ?");
statement.setInt(1, profile.getSkillLevel(SkillType.TAMING));
statement.setInt(2, profile.getSkillLevel(SkillType.MINING));
statement.setInt(3, profile.getSkillLevel(SkillType.REPAIR));
@@ -251,7 +239,11 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setInt(11, profile.getSkillLevel(SkillType.ACROBATICS));
statement.setInt(12, profile.getSkillLevel(SkillType.FISHING));
statement.setInt(13, profile.getSkillLevel(SkillType.ALCHEMY));
statement.setInt(14, id);
int total = 0;
for (SkillType skillType : SkillType.NON_CHILD_SKILLS)
total += profile.getSkillLevel(skillType);
statement.setInt(14, total);
statement.setInt(15, id);
success &= (statement.executeUpdate() != 0);
statement.close();
if (!success) {
@@ -337,7 +329,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("SELECT " + query + ", user, NOW() FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement = connection.prepareStatement("SELECT " + query + ", user FROM " + tablePrefix + "users JOIN " + tablePrefix + "skills ON (user_id = id) WHERE " + query + " > 0 AND NOT user = '\\_INVALID\\_OLD\\_USERNAME\\_' ORDER BY " + query + " DESC, user LIMIT ?, ?");
statement.setInt(1, (pageNumber * statsPerPage) - statsPerPage);
statement.setInt(2, statsPerPage);
resultSet = statement.executeQuery();
@@ -850,6 +842,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
+ "`acrobatics` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`fishing` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`alchemy` int(10) unsigned NOT NULL DEFAULT '0',"
+ "`total` int(10) unsigned NOT NULL DEFAULT '0',"
+ "PRIMARY KEY (`user_id`)) "
+ "DEFAULT CHARSET=latin1;");
tryClose(createStatement);
@@ -992,6 +985,10 @@ public final class SQLDatabaseManager implements DatabaseManager {
checkNameUniqueness(statement);
return;
case ADD_SKILL_TOTAL:
checkUpgradeSkillTotal(connection);
break;
default:
break;
@@ -1132,7 +1129,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
return DatabaseType.SQL;
}
private void checkNameUniqueness(final Statement statement) throws SQLException {
private void checkNameUniqueness(final Statement statement) {
ResultSet resultSet = null;
try {
resultSet = statement.executeQuery("SHOW INDEXES "
@@ -1205,7 +1202,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private void checkUpgradeAddSQLIndexes(final Statement statement) throws SQLException {
private void checkUpgradeAddSQLIndexes(final Statement statement) {
ResultSet resultSet = null;
try {
@@ -1292,7 +1289,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
if (!names.isEmpty()) {
new UUIDUpdateAsyncTask(mcMMO.p, names).run();;
new UUIDUpdateAsyncTask(mcMMO.p, names).run();
}
} finally {
massUpdateLock.unlock();
@@ -1329,6 +1326,43 @@ public final class SQLDatabaseManager implements DatabaseManager {
}
}
private void checkUpgradeSkillTotal(final Connection connection) throws SQLException {
ResultSet resultSet = null;
Statement statement = null;
try {
connection.setAutoCommit(false);
statement = connection.createStatement();
resultSet = statement.executeQuery("SELECT * FROM `" + tablePrefix + "skills` LIMIT 1");
ResultSetMetaData rsmeta = resultSet.getMetaData();
boolean column_exists = false;
for (int i = 1; i <= rsmeta.getColumnCount(); i++) {
if (rsmeta.getColumnName(i).equalsIgnoreCase("total")) {
column_exists = true;
break;
}
}
if (!column_exists) {
mcMMO.p.getLogger().info("Adding skill total column to skills table...");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD COLUMN `total` int NOT NULL DEFAULT '0'");
statement.executeUpdate("UPDATE `" + tablePrefix + "skills` SET `total` = (taming+mining+woodcutting+repair+unarmed+herbalism+excavation+archery+swords+axes+acrobatics+fishing+alchemy)");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "skills` ADD INDEX `idx_total` (`total`) USING BTREE");
connection.commit();
}
}
catch (SQLException ex) {
printErrors(ex);
}
finally {
connection.setAutoCommit(true);
tryClose(resultSet);
tryClose(statement);
}
}
private void checkUpgradeDropSpout(final Statement statement) {
ResultSet resultSet = null;
@@ -1415,6 +1449,25 @@ public final class SQLDatabaseManager implements DatabaseManager {
public enum PoolIdentifier {
MISC,
LOAD,
SAVE;
SAVE
}
public void resetMobHealthSettings() {
PreparedStatement statement = null;
Connection connection = null;
try {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.prepareStatement("UPDATE " + tablePrefix + "huds SET mobhealthbar = ?");
statement.setString(1, Config.getInstance().getMobHealthbarDefault().toString());
statement.executeUpdate();
}
catch (SQLException ex) {
printErrors(ex);
}
finally {
tryClose(statement);
tryClose(connection);
}
}
}

View File

@@ -11,5 +11,6 @@ public enum UpgradeType {
ADD_UUIDS,
ADD_UUIDS_PARTY,
ADD_SCOREBOARD_TIPS,
DROP_NAME_UNIQUENESS;
DROP_NAME_UNIQUENESS,
ADD_SKILL_TOTAL,
}

View File

@@ -1,5 +1,18 @@
package com.gmail.nossr50.datatypes.party;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
@@ -7,20 +20,6 @@ import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
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.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
public class Party {
private final LinkedHashMap<UUID, String> members = new LinkedHashMap<UUID, String>();
private final List<Player> onlineMembers = new ArrayList<Player>();
@@ -227,7 +226,7 @@ public class Party {
leader.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, getLevel()));
if (Config.getInstance().getLevelUpSoundsEnabled()) {
leader.playSound(leader.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
leader.playSound(leader.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
}
}
return;
@@ -337,7 +336,7 @@ public class Party {
}
if (!nearMembers.contains(member) && !playerName.equalsIgnoreCase(memberName)) {
memberList.append(ChatColor.ITALIC).append("");
memberList.append(ChatColor.ITALIC);
}
memberList.append(memberName).append(ChatColor.RESET).append(" ");

View File

@@ -1,21 +1,5 @@
package com.gmail.nossr50.datatypes.player;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
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.experience.ExperienceConfig;
@@ -28,9 +12,11 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.skills.AbilityDisableTask;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.runnables.skills.ToolLowerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
@@ -53,11 +39,23 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.PerksUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class McMMOPlayer {
private Player player;
@@ -504,7 +502,7 @@ public class McMMOPlayer {
}
if (Config.getInstance().getLevelUpSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
}
player.sendMessage(LocaleLoader.getString(StringUtils.getCapitalized(skillType.toString()) + ".Skillup", levelsGained, getSkillLevel(skillType)));
@@ -689,7 +687,7 @@ public class McMMOPlayer {
xp = (float) (xp / skillType.getXpModifier() * ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier());
if (Config.getInstance().getToolModsEnabled()) {
CustomTool tool = mcMMO.getModManager().getTool(player.getItemInHand());
CustomTool tool = mcMMO.getModManager().getTool(player.getInventory().getItemInMainHand());
if (tool != null) {
xp *= tool.getXpMultiplier();
@@ -773,7 +771,7 @@ public class McMMOPlayer {
return;
}
ItemStack inHand = player.getItemInHand();
ItemStack inHand = player.getInventory().getItemInMainHand();
if (mcMMO.getModManager().isCustomTool(inHand) && !mcMMO.getModManager().getTool(inHand).isAbilityEnabled()) {
return;

View File

@@ -21,7 +21,7 @@ public enum MaterialType {
return Material.LEATHER;
case WOOD:
return Material.WOOD;
return Material.OAK_PLANKS;
case STONE:
return Material.COBBLESTONE;

View File

@@ -64,7 +64,7 @@ public enum SecondaryAbility {
/* Taming */
BEAST_LORE,
CALL_OF_THE_WILD,
ENVIROMENTALLY_AWARE,
ENVIRONMENTALLY_AWARE,
FAST_FOOD,
GORE,
HOLY_HOUND,

View File

@@ -48,7 +48,7 @@ public enum SkillType {
SALVAGE(SalvageManager.class, Color.ORANGE, ImmutableList.of(SecondaryAbility.ADVANCED_SALVAGE, SecondaryAbility.ARCANE_SALVAGE)),
SMELTING(SmeltingManager.class, Color.YELLOW, ImmutableList.of(SecondaryAbility.FLUX_MINING, SecondaryAbility.FUEL_EFFICIENCY, SecondaryAbility.SECOND_SMELT)),
SWORDS(SwordsManager.class, Color.fromRGB(178, 34, 34), AbilityType.SERRATED_STRIKES, ToolType.SWORD, ImmutableList.of(SecondaryAbility.BLEED, SecondaryAbility.COUNTER)),
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIROMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)),
TAMING(TamingManager.class, Color.PURPLE, ImmutableList.of(SecondaryAbility.BEAST_LORE, SecondaryAbility.CALL_OF_THE_WILD, SecondaryAbility.ENVIRONMENTALLY_AWARE, SecondaryAbility.FAST_FOOD, SecondaryAbility.GORE, SecondaryAbility.HOLY_HOUND, SecondaryAbility.SHARPENED_CLAWS, SecondaryAbility.SHOCK_PROOF, SecondaryAbility.THICK_FUR, SecondaryAbility.PUMMEL)),
UNARMED(UnarmedManager.class, Color.BLACK, AbilityType.BERSERK, ToolType.FISTS, ImmutableList.of(SecondaryAbility.BLOCK_CRACKER, SecondaryAbility.DEFLECT, SecondaryAbility.DISARM, SecondaryAbility.IRON_ARM, SecondaryAbility.IRON_GRIP)),
WOODCUTTING(WoodcuttingManager.class, Color.OLIVE, AbilityType.TREE_FELLER, ToolType.AXE, ImmutableList.of(SecondaryAbility.LEAF_BLOWER, SecondaryAbility.WOODCUTTING_DOUBLE_DROPS));

View File

@@ -4,35 +4,44 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;
public class AlchemyPotion {
private short dataValue;
private Material material;
private PotionData data;
private String name;
private List<String> lore;
private List<PotionEffect> effects;
private Map<ItemStack, Short> children;
private Color color;
private Map<ItemStack, String> children;
public AlchemyPotion(short dataValue, String name, List<String> lore, List<PotionEffect> effects, Map<ItemStack, Short> children) {
this.dataValue = dataValue;
public AlchemyPotion(Material material, PotionData data, String name, List<String> lore, List<PotionEffect> effects, Color color, Map<ItemStack, String> children) {
this.material = material;
this.data = data;
this.lore = lore;
this.name = name;
this.effects = effects;
this.children = children;
this.color = color;
}
public String toString() {
return "AlchemyPotion{" + dataValue + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
return "AlchemyPotion{" + data + ", " + name + ", Effects[" + effects.size() + "], Children[" + children.size() + "]}";
}
public ItemStack toItemStack(int amount) {
ItemStack potion = new ItemStack(Material.POTION, amount, this.getDataValue());
ItemStack potion = new ItemStack(material, amount);
PotionMeta meta = (PotionMeta) potion.getItemMeta();
meta.setBasePotionData(data);
if (this.getName() != null) {
meta.setDisplayName(this.getName());
}
@@ -46,21 +55,29 @@ public class AlchemyPotion {
meta.addCustomEffect(effect, true);
}
}
if (this.getColor() != null) {
meta.setColor(this.getColor());
}
potion.setItemMeta(meta);
return potion;
}
public Material getMaterial() {
return material;
}
public Potion toPotion(int amount) {
return Potion.fromItemStack(this.toItemStack(amount));
}
public short getDataValue() {
return dataValue;
public PotionData getData() {
return data;
}
public void setDataValue(short data_value) {
this.dataValue = data_value;
public void setData(PotionData data) {
this.data = data;
}
public String getName() {
@@ -87,22 +104,65 @@ public class AlchemyPotion {
this.effects = effects;
}
public Map<ItemStack, Short> getChildren() {
public Color getColor() {
return color;
}
public void setColor(Color color) {
this.color = color;
}
public Map<ItemStack, String> getChildren() {
return children;
}
public void setChildren(Map<ItemStack, Short> children) {
public void setChildren(Map<ItemStack, String> children) {
this.children = children;
}
public Short getChildDataValue(ItemStack ingredient) {
public AlchemyPotion getChild(ItemStack ingredient) {
if (!children.isEmpty()) {
for (Entry<ItemStack, Short> child : children.entrySet()) {
for (Entry<ItemStack, String> child : children.entrySet()) {
if (ingredient.isSimilar(child.getKey())) {
return child.getValue();
return PotionConfig.getInstance().getPotion(child.getValue());
}
}
}
return -1;
return null;
}
public boolean isSimilar(ItemStack item) {
if (item.getType() != material) {
return false;
}
if (!item.hasItemMeta()) {
return false;
}
PotionMeta meta = (PotionMeta) item.getItemMeta();
PotionData that = meta.getBasePotionData();
if (data.getType() != that.getType()) {
return false;
}
if (data.isExtended() != that.isExtended()) {
return false;
}
if (data.isUpgraded() != that.isUpgraded()) {
return false;
}
for (PotionEffect effect : effects) {
if (!meta.hasCustomEffect(effect.getType())) {
return false;
}
}
if (!meta.hasLore() && !lore.isEmpty()) {
return false;
}
if (!(lore.isEmpty() && !meta.hasLore()) && !meta.getLore().equals(lore)) {
return false;
}
if (!meta.hasDisplayName() && name != null) {
return false;
}
return (name == null && !meta.hasDisplayName()) || meta.getDisplayName().equals(name);
}
}

View File

@@ -2,8 +2,11 @@ package com.gmail.nossr50.datatypes.skills.alchemy;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionData;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionType;
public enum PotionStage {
FIVE(5),
@@ -42,26 +45,25 @@ public enum PotionStage {
}
private static boolean isWaterBottle(AlchemyPotion input) {
return input.getDataValue() == 0;
return input.getData().getType() == PotionType.WATER;
}
public static PotionStage getPotionStage(AlchemyPotion alchemyPotion) {
Potion potion = alchemyPotion.toPotion(1);
PotionData data = alchemyPotion.getData();
List<PotionEffect> effects = alchemyPotion.getEffects();
int stage = 1;
// Check if potion isn't awkward or mundane
// Check for custom effects added by mcMMO
if (potion.getType() != null || !effects.isEmpty()) {
// Check if potion has an effect of any sort
if (data.getType().getEffectType() != null || !effects.isEmpty()) {
stage++;
}
// Check if potion has a glowstone dust amplifier
// Else check if the potion has a custom effect with an amplifier added by mcMMO
if (potion.getLevel() > 1) {
if (data.isUpgraded()) {
stage++;
}else if(!effects.isEmpty()){
} else if(!effects.isEmpty()) {
for (PotionEffect effect : effects){
if(effect.getAmplifier() > 0){
stage++;
@@ -71,12 +73,12 @@ public enum PotionStage {
}
// Check if potion has a redstone dust amplifier
if (potion.hasExtendedDuration()) {
if (data.isExtended()) {
stage++;
}
// Check if potion has a gunpowder amplifier
if (potion.isSplash()) {
if (alchemyPotion.getMaterial() == Material.SPLASH_POTION || alchemyPotion.getMaterial() == Material.LINGERING_POTION) {
stage++;
}

View File

@@ -64,8 +64,7 @@ public abstract class McMMOPlayerExperienceEvent extends PlayerEvent implements
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
/** Rest of file is required boilerplate for custom events **/
private static final HandlerList handlers = new HandlerList();
@Override

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
@@ -46,4 +47,15 @@ public class McMMOPlayerLevelDownEvent extends McMMOPlayerLevelChangeEvent {
public int getLevelsLost() {
return levelsLost;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
@@ -46,4 +47,15 @@ public class McMMOPlayerLevelUpEvent extends McMMOPlayerLevelChangeEvent {
public int getLevelsGained() {
return levelsGained;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -1,6 +1,7 @@
package com.gmail.nossr50.events.experience;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
@@ -51,4 +52,15 @@ public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
public void setXpGained(int xpGained) {
this.xpGained = xpGained;
}
private static final HandlerList handlers = new HandlerList();
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@@ -5,7 +5,7 @@ import org.bukkit.event.inventory.BrewEvent;
import org.bukkit.inventory.BrewerInventory;
public class FakeBrewEvent extends BrewEvent {
public FakeBrewEvent(Block brewer, BrewerInventory contents) {
super(brewer, contents);
public FakeBrewEvent(Block brewer, BrewerInventory contents, int fuelLevel) {
super(brewer, contents, fuelLevel);
}
}

View File

@@ -1,12 +1,12 @@
package com.gmail.nossr50.events.fake;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Fish;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
public class FakePlayerFishEvent extends PlayerFishEvent {
public FakePlayerFishEvent(Player player, Entity entity, Fish hookEntity, State state) {
public FakePlayerFishEvent(Player player, Entity entity, FishHook hookEntity, State state) {
super(player, entity, hookEntity, state);
}
}

View File

@@ -0,0 +1,58 @@
package com.gmail.nossr50.events.skills.salvage;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.skills.McMMOPlayerSkillEvent;
/**
* Called just before a player salvages an item with mcMMO.
*/
public class McMMOPlayerSalvageCheckEvent extends McMMOPlayerSkillEvent implements Cancellable {
private ItemStack salvageItem;
private ItemStack salvageResults;
private ItemStack enchantedBook;
private boolean cancelled;
public McMMOPlayerSalvageCheckEvent(Player player, ItemStack salvageItem, ItemStack salvageResults, ItemStack enchantedBook) {
super(player, SkillType.SALVAGE);
this.salvageItem = salvageItem;
this.salvageResults = salvageResults;
this.enchantedBook = enchantedBook;
this.cancelled = false;
}
/**
* @return The item that should get salvaged.
*/
public ItemStack getSalvageItem() {
return salvageItem;
}
/**
* @return The results that should be dropped after salvaging.
*/
public ItemStack getSalvageResults() {
return salvageResults;
}
/**
* @return The enchanted book that should drop after salvaging or null if no book should be dropped.
*/
public ItemStack getEnchantedBook() {
return enchantedBook;
}
/** Following are required for Cancellable **/
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
}

View File

@@ -1,11 +1,27 @@
package com.gmail.nossr50.listeners;
import java.util.List;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
@@ -16,44 +32,14 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import com.gmail.nossr50.events.fake.FakeBlockDamageEvent;
import com.gmail.nossr50.runnables.PistonTrackerTask;
import com.gmail.nossr50.runnables.StickyPistonTrackerTask;
import com.gmail.nossr50.skills.alchemy.Alchemy;
import com.gmail.nossr50.skills.excavation.ExcavationManager;
import com.gmail.nossr50.skills.herbalism.Herbalism;
import com.gmail.nossr50.skills.herbalism.HerbalismManager;
import com.gmail.nossr50.skills.mining.MiningManager;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.skills.woodcutting.WoodcuttingManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import java.util.List;
public class BlockListener implements Listener {
private final mcMMO plugin;
@@ -69,24 +55,15 @@ public class BlockListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
BlockFace direction = event.getDirection();
Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished
Block movedBlock = event.getBlock();
movedBlock = movedBlock.getRelative(direction, 2);
if (futureEmptyBlock.getType() == Material.AIR) {
return;
}
List<Block> blocks = event.getBlocks();
for (Block b : blocks) {
for (Block b : event.getBlocks()) {
if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
Block nextBlock = b.getRelative(direction);
mcMMO.getPlaceStore().setTrue(nextBlock);
//b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
movedBlock = b.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
}
}
// Needed because blocks sometimes don't move when two pistons push towards each other
//new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
}
/**
@@ -96,36 +73,15 @@ public class BlockListener implements Listener {
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
// event.isSticky() always returns false
// if (!event.isSticky()){
// return;
// }
// Sticky piston return PISTON_MOVING_PIECE and normal piston PISTON_BASE
if (event.getBlock().getType() != Material.PISTON_MOVING_PIECE) {
return;
}
// Get opposite direction so we get correct block
BlockFace direction = event.getDirection().getOppositeFace();
BlockFace direction = event.getDirection();
Block movedBlock = event.getBlock().getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
// If we're pulling a slime block, it might have something attached to it!
if (movedBlock.getRelative(direction).getState().getType() == Material.SLIME_BLOCK) {
for (Block block : event.getBlocks()) {
movedBlock = block.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
// // Treat the slime blocks as if it is the sticky piston itself, because pulling
// // a slime block with a sticky piston is effectively the same as moving a sticky piston.
// new StickyPistonTrackerTask(direction, event.getBlock(), block).runTaskLater(plugin, 2);
}
return;
for (Block block : event.getBlocks()) {
movedBlock = block.getRelative(direction);
mcMMO.getPlaceStore().setTrue(movedBlock);
}
// Needed only because under some circumstances Minecraft doesn't move the block
//new StickyPistonTrackerTask(direction, event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
/**
@@ -172,8 +128,10 @@ public class BlockListener implements Listener {
BlockState blockState = event.getBlock().getState();
/* Check if the blocks placed should be monitored so they do not give out XP in the future */
if (BlockUtils.shouldBeWatched(blockState)) {
mcMMO.getPlaceStore().setTrue(blockState);
if (BlockUtils.shouldBeWatched(blockState) && blockState.getType() != Material.CHORUS_FLOWER) {
// Don't count de-barking wood
if (!Tag.LOGS.isTagged(event.getBlockReplacedState().getType()) || !Tag.LOGS.isTagged(event.getBlockPlaced().getType()))
mcMMO.getPlaceStore().setTrue(blockState);
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
@@ -186,6 +144,18 @@ public class BlockListener implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockGrow(BlockGrowEvent event)
{
BlockState blockState = event.getBlock().getState();
if (!BlockUtils.shouldBeWatched(blockState)) {
return;
}
mcMMO.getPlaceStore().setFalse(blockState);
}
/**
* Monitor BlockBreak events.
*
@@ -216,7 +186,7 @@ public class BlockListener implements Listener {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
/* HERBALISM */
if (BlockUtils.affectedByGreenTerra(blockState)) {
@@ -245,7 +215,6 @@ public class BlockListener implements Listener {
/* WOOD CUTTING */
else if (BlockUtils.isLog(blockState) && ItemUtils.isAxe(heldItem) && SkillType.WOODCUTTING.getPermissions(player) && !mcMMO.getPlaceStore().isTrue(blockState)) {
WoodcuttingManager woodcuttingManager = mcMMOPlayer.getWoodcuttingManager();
if (woodcuttingManager.canUseTreeFeller(heldItem)) {
woodcuttingManager.processTreeFeller(blockState);
}
@@ -286,7 +255,7 @@ public class BlockListener implements Listener {
}
BlockState blockState = event.getBlock().getState();
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (Herbalism.isRecentlyRegrown(blockState)) {
event.setCancelled(true);
@@ -346,7 +315,7 @@ public class BlockListener implements Listener {
* We check permissions here before processing activation.
*/
if (BlockUtils.canActivateAbilities(blockState)) {
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (HiddenConfig.getInstance().useEnchantmentBuffs()) {
if ((ItemUtils.isPickaxe(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.SUPER_BREAKER)) || (ItemUtils.isShovel(heldItem) && !mcMMOPlayer.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER))) {
@@ -382,7 +351,7 @@ public class BlockListener implements Listener {
* We don't need to check permissions here because they've already been checked for the ability to even activate.
*/
if (mcMMOPlayer.getAbilityMode(AbilityType.TREE_FELLER) && BlockUtils.isLog(blockState) && Config.getInstance().getTreeFellerSoundsEnabled()) {
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
}
}
@@ -404,7 +373,7 @@ public class BlockListener implements Listener {
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
Block block = event.getBlock();
BlockState blockState = block.getState();
@@ -421,7 +390,7 @@ public class BlockListener implements Listener {
else if (mcMMOPlayer.getAbilityMode(AbilityType.BERSERK) && heldItem.getType() == Material.AIR) {
if (AbilityType.BERSERK.blockCheck(block.getState()) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
player.playSound(block.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.playSound(block.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
else if (mcMMOPlayer.getUnarmedManager().canUseBlockCracker() && BlockUtils.affectedByBlockCracker(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
if (mcMMOPlayer.getUnarmedManager().blockCrackerCheck(blockState)) {
@@ -431,7 +400,7 @@ public class BlockListener implements Listener {
}
else if (mcMMOPlayer.getWoodcuttingManager().canUseLeafBlower(heldItem) && BlockUtils.isLeaves(blockState) && EventUtils.simulateBlockBreak(block, player, true)) {
event.setInstaBreak(true);
player.playSound(blockState.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.playSound(blockState.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
}
}
}

View File

@@ -1,46 +1,5 @@
package com.gmail.nossr50.listeners;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.EntityTameEvent;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.ExplosionPrimeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -48,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
@@ -64,6 +24,23 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
public class EntityListener implements Listener {
private final mcMMO plugin;
@@ -131,8 +108,7 @@ public class EntityListener implements Listener {
else if (isTracked) {
mcMMO.getPlaceStore().setTrue(block);
}
}
else if ((block.getType() == Material.REDSTONE_ORE || block.getType() == Material.GLOWING_REDSTONE_ORE) && (event.getTo() == Material.REDSTONE_ORE || event.getTo() == Material.GLOWING_REDSTONE_ORE)) {
} else if ((block.getType() == Material.REDSTONE_ORE)) {
return;
}
else {
@@ -154,6 +130,16 @@ public class EntityListener implements Listener {
return;
}
if (event.getEntity() instanceof ArmorStand) {
return;
}
if (event.getDamager().hasMetadata(mcMMO.funfettiMetadataKey))
{
event.setCancelled(true);
return;
}
double damage = event.getFinalDamage();
Entity defender = event.getEntity();
Entity attacker = event.getDamager();
@@ -409,6 +395,10 @@ public class EntityListener implements Listener {
entity.setCustomNameVisible(entity.getMetadata(mcMMO.customVisibleKey).get(0).asBoolean());
entity.removeMetadata(mcMMO.customVisibleKey, plugin);
}
if (entity.hasMetadata(mcMMO.entityMetadataKey)) {
entity.removeMetadata(mcMMO.entityMetadataKey, plugin);
}
}
/**
@@ -570,13 +560,14 @@ public class EntityListener implements Listener {
* is based on how 'common' the item is We can adjust this quite easily
* if we find something is giving too much of a bonus
*/
switch (player.getItemInHand().getType()) {
switch (player.getInventory().getItemInMainHand().getType()) {
case BAKED_POTATO: /*
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000
*/
case BEETROOT:
case BREAD: /* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @ 1000 */
case CARROT_ITEM: /*
case CARROT: /*
* RESTORES 2 HUNGER - RESTORES 4 1/2 HUNGER @
* 1000
*/
@@ -584,7 +575,7 @@ public class EntityListener implements Listener {
* RESTORES 3 HUNGER - RESTORES 5 1/2 HUNGER @
* 1000
*/
case MUSHROOM_SOUP: /*
case MUSHROOM_STEW: /*
* RESTORES 4 HUNGER - RESTORES 6 1/2 HUNGER @
* 1000
*/
@@ -598,18 +589,18 @@ public class EntityListener implements Listener {
return;
case COOKIE: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case MELON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case MELON_SLICE: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case POISONOUS_POTATO: /*
* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER
* @ 1000
*/
case POTATO_ITEM: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
case POTATO: /* RESTORES 1/2 HUNGER - RESTORES 2 HUNGER @ 1000 */
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FARMERS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getHerbalismManager().farmersDiet(Herbalism.farmersDietRankLevel2, newFoodLevel));
}
return;
case COOKED_FISH: /*
case COOKED_SALMON: /*
* RESTORES 2 1/2 HUNGER - RESTORES 5 HUNGER @
* 1000
*/
@@ -618,7 +609,7 @@ public class EntityListener implements Listener {
}
return;
case RAW_FISH: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
case SALMON: /* RESTORES 1 HUNGER - RESTORES 2 1/2 HUNGER @ 1000 */
if (Permissions.secondaryAbilityEnabled(player, SecondaryAbility.FISHERMANS_DIET)) {
event.setFoodLevel(UserManager.getPlayer(player).getFishingManager().handleFishermanDiet(Fishing.fishermansDietRankLevel2, newFoodLevel));
}
@@ -702,4 +693,11 @@ public class EntityListener implements Listener {
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPigZapEvent(PigZapEvent event) {
if (event.getEntity().hasMetadata(mcMMO.entityMetadataKey)) {
event.getPigZombie().setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
}
}
}

View File

@@ -2,6 +2,9 @@ package com.gmail.nossr50.listeners;
import java.util.List;
import com.gmail.nossr50.events.fake.FakeBrewEvent;
import com.gmail.nossr50.skills.alchemy.AlchemyManager;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@@ -12,18 +15,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.FurnaceBurnEvent;
import org.bukkit.event.inventory.FurnaceExtractEvent;
import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.BrewerInventory;
import org.bukkit.inventory.FurnaceInventory;
import org.bukkit.inventory.Inventory;
@@ -124,10 +116,8 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onFurnaceExtractEvent(FurnaceExtractEvent event) {
Block furnaceBlock = event.getBlock();
BlockState furnaceState = furnaceBlock.getState();
ItemStack result = furnaceState instanceof Furnace ? ((Furnace) furnaceState).getInventory().getResult() : null;
if (!ItemUtils.isSmelted(result)) {
if (!ItemUtils.isSmelted(new ItemStack(event.getItemType(), event.getItemAmount()))) {
return;
}
@@ -137,7 +127,8 @@ public class InventoryListener implements Listener {
return;
}
event.setExpToDrop(UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop()));
int exp = UserManager.getPlayer(player).getSmeltingManager().vanillaXPBoost(event.getExpToDrop());
event.setExpToDrop(exp);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
@@ -165,7 +156,7 @@ public class InventoryListener implements Listener {
ItemStack clicked = event.getCurrentItem();
ItemStack cursor = event.getCursor();
if ((clicked != null && clicked.getType() == Material.POTION) || (cursor != null && cursor.getType() == Material.POTION)) {
if ((clicked != null && (clicked.getType() == Material.POTION || clicked.getType() == Material.SPLASH_POTION || clicked.getType() == Material.LINGERING_POTION)) || (cursor != null && (cursor.getType() == Material.POTION || cursor.getType() == Material.SPLASH_POTION || cursor.getType() == Material.LINGERING_POTION))) {
AlchemyPotionBrewer.scheduleCheck(player, stand);
return;
}
@@ -280,6 +271,19 @@ public class InventoryListener implements Listener {
}
}
// Apparently sometimes vanilla brewing beats our task listener to the actual brew. We handle this by cancelling the vanilla event and finishing our brew ourselves.
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBrew(BrewEvent event)
{
if (event instanceof FakeBrewEvent)
return;
Location location = event.getBlock().getLocation();
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.get(location).finishImmediately();
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onInventoryMoveItemEvent(InventoryMoveItemEvent event) {
Inventory inventory = event.getDestination();
@@ -296,12 +300,12 @@ public class InventoryListener implements Listener {
ItemStack item = event.getItem();
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION) {
if (Config.getInstance().getPreventHopperTransferIngredients() && item.getType() != Material.POTION && item.getType() != Material.SPLASH_POTION && item.getType() != Material.LINGERING_POTION) {
event.setCancelled(true);
return;
}
if (Config.getInstance().getPreventHopperTransferBottles() && item.getType() == Material.POTION) {
if (Config.getInstance().getPreventHopperTransferBottles() && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION)) {
event.setCancelled(true);
return;
}
@@ -321,7 +325,7 @@ public class InventoryListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onInventoryOpenEvent(InventoryOpenEvent event) {
SkillUtils.removeAbilityBuff(event.getPlayer().getItemInHand());
SkillUtils.removeAbilityBuff(event.getPlayer().getInventory().getItemInMainHand());
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)

View File

@@ -1,36 +1,5 @@
package com.gmail.nossr50.listeners;
import java.util.HashSet;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
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.PlayerPickupItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.chat.ChatManager;
import com.gmail.nossr50.chat.ChatManagerFactory;
import com.gmail.nossr50.chat.PartyChatManager;
@@ -42,6 +11,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.party.ShareHandler;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.skills.fishing.FishingManager;
@@ -53,17 +23,22 @@ import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.skills.salvage.SalvageManager;
import com.gmail.nossr50.skills.taming.TamingManager;
import com.gmail.nossr50.skills.unarmed.Unarmed;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.HardcoreManager;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.MobHealthbarUtils;
import com.gmail.nossr50.util.Motd;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.*;
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.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class PlayerListener implements Listener {
private final mcMMO plugin;
@@ -223,13 +198,16 @@ public class PlayerListener implements Listener {
event.setCancelled(fishingManager.exploitPrevention());
}
return;
case CAUGHT_FISH:
//TODO Update to new API once available! Waiting for case CAUGHT_TREASURE:
Item fishingCatch = (Item) event.getCaught();
if (Config.getInstance().getFishingOverrideTreasures() && fishingCatch.getItemStack().getType() != Material.RAW_FISH) {
fishingCatch.setItemStack(new ItemStack(Material.RAW_FISH, 1));
if (Config.getInstance().getFishingOverrideTreasures() &&
fishingCatch.getItemStack().getType() != Material.SALMON &&
fishingCatch.getItemStack().getType() != Material.COD &&
fishingCatch.getItemStack().getType() != Material.TROPICAL_FISH &&
fishingCatch.getItemStack().getType() != Material.PUFFERFISH) {
fishingCatch.setItemStack(new ItemStack(Material.SALMON, 1));
}
if (Permissions.vanillaXpBoost(player, SkillType.FISHING)) {
@@ -238,7 +216,7 @@ public class PlayerListener implements Listener {
return;
case IN_GROUND:
Block block = player.getTargetBlock((HashSet<Byte>) null, 100);
Block block = player.getTargetBlock(null, 100);
if (fishingManager.canIceFish(block)) {
event.setCancelled(true);
@@ -325,18 +303,18 @@ public class PlayerListener implements Listener {
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
if (event.isCancelled()) {
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
return;
}
}
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack)) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
if ((mcMMOPlayer.isUsingUnarmed() && ItemUtils.isSharable(dropStack) && !Config.getInstance().getUnarmedItemsAsUnarmed()) || mcMMOPlayer.getAbilityMode(AbilityType.BERSERK)) {
boolean pickupSuccess = Unarmed.handleItemPickup(player.getInventory(), drop);
boolean cancel = Config.getInstance().getUnarmedItemPickupDisabled() || pickupSuccess;
event.setCancelled(cancel);
if (pickupSuccess) {
player.playSound(player.getLocation(), Sound.ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, Misc.POP_VOLUME, Misc.getPopPitch());
player.updateInventory();
return;
}
@@ -390,11 +368,6 @@ public class PlayerListener implements Listener {
if (plugin.isXPEventEnabled()) {
player.sendMessage(LocaleLoader.getString("XPRate.Event", ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier()));
}
if (Permissions.updateNotifications(player) && plugin.isUpdateAvailable()) {
player.sendMessage(LocaleLoader.getString("UpdateChecker.Outdated"));
player.sendMessage(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
}
/**
@@ -426,14 +399,14 @@ public class PlayerListener implements Listener {
public void onPlayerInteractLowest(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
MiningManager miningManager = mcMMOPlayer.getMiningManager();
Block block = event.getClickedBlock();
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
@@ -479,7 +452,7 @@ public class PlayerListener implements Listener {
case LEFT_CLICK_BLOCK:
type = block.getType();
if ((Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() && player.isSneaking()) || !Config.getInstance().getAbilitiesOnlyActivateWhenSneaking()) {
if (!Config.getInstance().getAbilitiesOnlyActivateWhenSneaking() || player.isSneaking()) {
/* REPAIR CHECKS */
if (type == Repair.anvilMaterial && SkillType.REPAIR.getPermissions(player) && mcMMO.getRepairableManager().isRepairable(heldItem)) {
RepairManager repairManager = mcMMOPlayer.getRepairManager();
@@ -518,15 +491,19 @@ public class PlayerListener implements Listener {
public void onPlayerInteractMonitor(PlayerInteractEvent event) {
Player player = event.getPlayer();
if (!UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
if (event.getHand() != EquipmentSlot.HAND || !UserManager.hasPlayerDataKey(player) || player.getGameMode() == GameMode.CREATIVE) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
switch (event.getAction()) {
case RIGHT_CLICK_BLOCK:
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break;
}
Block block = event.getClickedBlock();
BlockState blockState = block.getState();
@@ -551,8 +528,20 @@ public class PlayerListener implements Listener {
/* GREEN THUMB CHECK */
HerbalismManager herbalismManager = mcMMOPlayer.getHerbalismManager();
if (heldItem.getType() == Material.BONE_MEAL) {
switch (blockState.getType()) {
case BEETROOTS:
case CARROT:
case COCOA:
case WHEAT:
case NETHER_WART_BLOCK:
case POTATO:
mcMMO.getPlaceStore().setFalse(blockState);
}
}
if (herbalismManager.canGreenThumbBlock(blockState)) {
player.setItemInHand(new ItemStack(Material.SEEDS, heldItem.getAmount() - 1));
player.getInventory().setItemInMainHand(new ItemStack(Material.WHEAT_SEEDS, heldItem.getAmount() - 1));
if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
@@ -561,6 +550,7 @@ public class PlayerListener implements Listener {
/* SHROOM THUMB CHECK */
else if (herbalismManager.canUseShroomThumb(blockState)) {
event.setCancelled(true);
if (herbalismManager.processShroomThumb(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
blockState.update(true);
}
@@ -568,7 +558,10 @@ public class PlayerListener implements Listener {
break;
case RIGHT_CLICK_AIR:
if(player.getInventory().getItemInOffHand().getType() != Material.AIR && !player.isInsideVehicle() && !player.isSneaking()) {
break;
}
/* ACTIVATION CHECKS */
if (Config.getInstance().getAbilitiesEnabled()) {
mcMMOPlayer.processAbilityActivation(SkillType.AXES);

View File

@@ -1,5 +1,6 @@
package com.gmail.nossr50.listeners;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -44,9 +45,10 @@ public class SelfListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerXpGain(McMMOPlayerXpGainEvent event) {
if (event.getXpGainReason() == XPGainReason.COMMAND)
return;
SkillType skillType = event.getSkill();
int threshold = ExperienceConfig.getInstance().getDiminishedReturnsThreshold(skillType);
if (threshold <= 0 || !ExperienceConfig.getInstance().getDiminishedReturnsEnabled()) {
// Diminished returns is turned off
return;

View File

@@ -1,17 +1,5 @@
package com.gmail.nossr50;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
@@ -26,17 +14,10 @@ import com.gmail.nossr50.config.skills.salvage.SalvageConfigManager;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
import com.gmail.nossr50.listeners.BlockListener;
import com.gmail.nossr50.listeners.EntityListener;
import com.gmail.nossr50.listeners.InventoryListener;
import com.gmail.nossr50.listeners.PlayerListener;
import com.gmail.nossr50.listeners.SelfListener;
import com.gmail.nossr50.listeners.WorldListener;
import com.gmail.nossr50.metrics.MetricsManager;
import com.gmail.nossr50.listeners.*;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.runnables.CheckDateTask;
import com.gmail.nossr50.runnables.SaveTimerTask;
import com.gmail.nossr50.runnables.UpdaterResultAsyncTask;
import com.gmail.nossr50.runnables.backups.CleanBackupsTask;
import com.gmail.nossr50.runnables.database.UserPurgeTask;
import com.gmail.nossr50.runnables.party.PartyAutoKickTask;
@@ -53,12 +34,7 @@ import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.skills.salvage.salvageables.SalvageableManager;
import com.gmail.nossr50.skills.salvage.salvageables.SimpleSalvageableManager;
import com.gmail.nossr50.skills.smelting.SmeltingManager;
import com.gmail.nossr50.util.ChimaeraWing;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.LogFilter;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.ModManager;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager;
import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.util.commands.CommandRegistrationManager;
@@ -66,8 +42,22 @@ import com.gmail.nossr50.util.experience.FormulaManager;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.upgrade.UpgradeManager;
import com.google.common.base.Charsets;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public class mcMMO extends JavaPlugin {
/* Managers */
@@ -91,9 +81,6 @@ public class mcMMO extends JavaPlugin {
// Jar Stuff
public static File mcmmo;
// Update Check
private boolean updateAvailable;
/* Plugin Checks */
private static boolean healthBarPluginEnabled;
@@ -108,6 +95,7 @@ public class mcMMO extends JavaPlugin {
public final static String blockMetadataKey = "mcMMO: Piston Tracking";
public final static String furnaceMetadataKey = "mcMMO: Tracked Furnace";
public final static String tntMetadataKey = "mcMMO: Tracked TNT";
public final static String funfettiMetadataKey = "mcMMO: Funfetti";
public final static String tntsafeMetadataKey = "mcMMO: Safe TNT";
public final static String customNameKey = "mcMMO: Custom Name";
public final static String customVisibleKey = "mcMMO: Name Visibility";
@@ -181,12 +169,8 @@ public class mcMMO extends JavaPlugin {
scheduleTasks();
CommandRegistrationManager.registerCommands();
MetricsManager.setup();
placeStore = ChunkManagerFactory.getChunkManager(); // Get our ChunkletManager
checkForUpdates();
if (Config.getInstance().getPTPCommandWorldPermissions()) {
Permissions.generateWorldTeleportPermissions();
}
@@ -267,14 +251,6 @@ public class mcMMO extends JavaPlugin {
return modDirectory;
}
public boolean isUpdateAvailable() {
return updateAvailable;
}
public void setUpdateAvailable(boolean available) {
this.updateAvailable = available;
}
public boolean isXPEventEnabled() {
return xpEventEnabled;
}
@@ -393,14 +369,6 @@ public class mcMMO extends JavaPlugin {
currentFlatfilePath.mkdirs();
}
private void checkForUpdates() {
if (!Config.getInstance().getUpdateCheckEnabled()) {
return;
}
new UpdaterResultAsyncTask(this).runTaskAsynchronously(mcMMO.p);
}
private void loadConfigFiles() {
// Force the loading of config files
TreasureConfig.getInstance();
@@ -454,17 +422,19 @@ public class mcMMO extends JavaPlugin {
}
private void registerCustomRecipes() {
if (Config.getInstance().getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
if (Config.getInstance().getChimaeraEnabled()) {
getServer().addRecipe(ChimaeraWing.getChimaeraWingRecipe());
}
if (Config.getInstance().getFluxPickaxeEnabled()) {
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.DIAMOND_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.GOLD_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.IRON_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.STONE_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.WOOD_PICKAXE));
}
if (Config.getInstance().getFluxPickaxeEnabled()) {
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.DIAMOND_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.GOLDEN_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.IRON_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.STONE_PICKAXE));
getServer().addRecipe(SmeltingManager.getFluxPickaxeRecipe(Material.WOODEN_PICKAXE));
}
}, 40);
}
private void scheduleTasks() {
@@ -532,4 +502,9 @@ public class mcMMO extends JavaPlugin {
getLogger().info("To enable, set Mods.Entity_Mods_Enabled to TRUE in config.yml.");
}
}
public InputStreamReader getResourceAsReader(String fileName) {
InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
}
}

View File

@@ -1,353 +0,0 @@
package com.gmail.nossr50.metrics;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Locale;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.HiddenConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.turt2live.metrics.EMetrics;
import com.turt2live.metrics.Metrics;
import com.turt2live.metrics.Metrics.Graph;
import com.turt2live.metrics.data.DataEvent;
import com.turt2live.metrics.data.DataTracker;
import com.turt2live.metrics.tracker.Tracker;
public class MetricsManager {
private static boolean setup = false;
private static Tracker chimeraUseTracker;
private static Tracker chimeraServerUseTracker;
private static boolean customConfig = false;
private static DataTracker tracker;
private static EMetrics emetrics;
public static void setup() {
if (setup) {
return;
}
if (Config.getInstance().getStatsTrackingEnabled()) {
try {
emetrics = new EMetrics(mcMMO.p);
Metrics metrics = emetrics.getMetrics();
// Timings Graph
Graph timingsGraph = metrics.createGraph("Percentage of servers using timings");
if (mcMMO.p.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 = mcMMO.p.getDescription().getVersion();
InputStreamReader isr = new InputStreamReader(mcMMO.p.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;
}
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;
}
});
// ExperienceFormulaShape Graph
Graph experienceFormulaShapeGraph = metrics.createGraph("Experience Formula Shape Graph");
experienceFormulaShapeGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getFormulaType().toString()) {
@Override
public int getValue() {
return 1;
}
});
// GlobalMultiplier Graph
Graph globalMultiplierGraph = metrics.createGraph("Global Multiplier Graph");
globalMultiplierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() + "") {
@Override
public int getValue() {
return 1;
}
});
// GlobalCurveModifier Graph
Graph globalCurveModifierGraph = metrics.createGraph("Global Curve Modifier Graph");
globalCurveModifierGraph.addPlotter(new Metrics.Plotter(ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) + "") {
@Override
public int getValue() {
return 1;
}
});
// GlobalMultiplierGraph Fuzzy Logic Numbers
Graph globalMultiplierGraphFuzzy = metrics.createGraph("Global Multiplier Fuzz");
if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() > 1.0) {
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
@Override
public int getValue() {
return 1;
}
});
}
else if (ExperienceConfig.getInstance().getExperienceGainsGlobalMultiplier() < 1.0) {
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
@Override
public int getValue() {
return 1;
}
});
}
else {
globalMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
@Override
public int getValue() {
return 1;
}
});
}
// GlobalCurveModifier Fuzzy Logic Numbers
Graph globalCurveMultiplierGraphFuzzy = metrics.createGraph("Global Curve Multiplier Fuzz");
if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) > 20.0) {
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Higher") {
@Override
public int getValue() {
return 1;
}
});
}
else if (ExperienceConfig.getInstance().getMultiplier(FormulaType.LINEAR) < 20.0) {
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Lower") {
@Override
public int getValue() {
return 1;
}
});
}
else {
globalCurveMultiplierGraphFuzzy.addPlotter(new Metrics.Plotter("Default") {
@Override
public int getValue() {
return 1;
}
});
}
// Chimera Wing Usage Trackers
final String chimeraGraphName = "Chimera Wing Usage";
chimeraUseTracker = EMetrics.createBasicTracker(chimeraGraphName, "Player use");
chimeraServerUseTracker = EMetrics.createEnabledTracker(chimeraGraphName, "Server use");
emetrics.addTracker(chimeraUseTracker);
emetrics.addTracker(chimeraServerUseTracker);
// Chimera Wing Enabled Graph
Graph chimeraGraph = metrics.createGraph("Chimera Wing");
if (Config.getInstance().getChimaeraEnabled()) {
chimeraGraph.addPlotter(new Metrics.Plotter("Enabled") {
@Override
public int getValue() {
return 1;
}
});
}
else {
chimeraGraph.addPlotter(new Metrics.Plotter("Disabled") {
@Override
public int getValue() {
return 1;
}
});
}
// Vanilla v Modified config graph
Graph customConfigGraph = metrics.createGraph("Modified Configs");
if (customConfig) {
customConfigGraph.addPlotter(new Metrics.Plotter("Edited") {
@Override
public int getValue() {
return 1;
}
});
}
else {
customConfigGraph.addPlotter(new Metrics.Plotter("Vanilla") {
@Override
public int getValue() {
return 1;
}
});
}
/*
* Debug stuff
* tracker = emetrics.getDataTracker();
* tracker.enable();
* tracker.setFilter(new DataEvent.DataType [] { DataEvent.DataType.SEND_DATA });
*/
emetrics.startMetrics();
}
catch (IOException e) {
mcMMO.p.getLogger().warning("Failed to submit stats.");
}
}
}
public static void chimeraWingUsed() {
chimeraUseTracker.increment();
chimeraServerUseTracker.increment();
}
public static void customConfig() {
customConfig = true;
}
@SuppressWarnings("unused")
private static void debug() {
emetrics.getMetrics().flush();
for (DataEvent event : tracker.getEvents()) {
String graphName = event.getGraphName();
String colName = event.getTrackerName();
int value = event.getValueSent();
System.out.println("Graph: " + graphName + ", Column: " + colName + ", Value: " + value);
}
tracker.resetEvents();
}
}

View File

@@ -1,18 +1,5 @@
package com.gmail.nossr50.party;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.chat.ChatMode;
import com.gmail.nossr50.datatypes.database.UpgradeType;
@@ -26,8 +13,20 @@ import com.gmail.nossr50.events.party.McMMOPartyAllianceChangeEvent;
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.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
public final class PartyManager {
private static String partiesFilePath = mcMMO.getFlatFileDirectory() + "parties.yml";
@@ -71,9 +70,7 @@ public final class PartyManager {
removeFromParty(mcMMOPlayer);
}
else if (!handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY)) {
return false;
}
else return handlePartyChangeEvent(player, null, newPartyName, EventReason.JOINED_PARTY);
return true;
}
@@ -729,7 +726,7 @@ public final class PartyManager {
member.sendMessage(LocaleLoader.getString("Party.LevelUp", levelsGained, level));
if (levelUpSoundsEnabled) {
member.playSound(member.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
member.playSound(member.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
}
}
}

View File

@@ -157,7 +157,7 @@ public final class ShareHandler {
private static void awardDrop(Player winningPlayer, ItemStack drop) {
if (winningPlayer.getInventory().addItem(drop).size() != 0) {
winningPlayer.getWorld().dropItemNaturally(winningPlayer.getLocation(), drop);
winningPlayer.getWorld().dropItem(winningPlayer.getLocation(), drop);
}
winningPlayer.updateInventory();

View File

@@ -1,36 +0,0 @@
package com.gmail.nossr50.runnables;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
import net.gravitydevelopment.updater.mcmmo.Updater;
public class UpdaterResultAsyncTask extends BukkitRunnable {
private mcMMO plugin;
public UpdaterResultAsyncTask(mcMMO plugin) {
this.plugin = plugin;
}
@Override
public void run() {
Updater updater = new Updater(plugin, 31030, plugin.mcmmo, Updater.UpdateType.NO_DOWNLOAD, false);
if (updater.getResult() != Updater.UpdateResult.UPDATE_AVAILABLE) {
plugin.setUpdateAvailable(false);
return;
}
if (updater.getLatestType().equals("beta") && !Config.getInstance().getPreferBeta()) {
plugin.setUpdateAvailable(false);
return;
}
plugin.setUpdateAvailable(true);
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.Outdated"));
plugin.getLogger().info(LocaleLoader.getString("UpdateChecker.NewAvailable"));
}
}

View File

@@ -1,17 +1,16 @@
package com.gmail.nossr50.runnables.commands;
import java.util.List;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import java.util.List;
/**
* Display the results of {@link MctopCommandAsyncTask} to the sender.
@@ -45,15 +44,27 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
if (sender instanceof Player) {
((Player) sender).removeMetadata(mcMMO.databaseCommandKey, mcMMO.p);
}
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
if(sender instanceof Player)
sender.sendMessage(LocaleLoader.getString("Commands.mctop.Tip"));
}
private void displayChat() {
if (skill == null) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
if(sender instanceof Player) {
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Leaderboard"));
}
else {
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.PowerLevel.Leaderboard")));
}
}
else {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
if(sender instanceof Player) {
sender.sendMessage(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName()));
}
else {
sender.sendMessage(ChatColor.stripColor(LocaleLoader.getString("Commands.Skill.Leaderboard", skill.getName())));
}
}
int place = (page * 10) - 9;
@@ -62,7 +73,13 @@ public class MctopCommandDisplayTask extends BukkitRunnable {
// Format:
// 01. Playername - skill value
// 12. Playername - skill value
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
if(sender instanceof Player) {
sender.sendMessage(String.format("%2d. %s%s - %s%s", place, ChatColor.GREEN, stat.name, ChatColor.WHITE, stat.statVal));
}
else {
sender.sendMessage(String.format("%2d. %s - %s", place, stat.name, stat.statVal));
}
place++;
}
}

View File

@@ -31,10 +31,11 @@ public class ChimaeraWingWarmup extends BukkitRunnable {
if (player.getLocation().distanceSquared(previousLocation) > 1.0 || !player.getInventory().containsAtLeast(ChimaeraWing.getChimaeraWing(0), 1)) {
player.sendMessage(LocaleLoader.getString("Teleport.Cancelled"));
mcMMOPlayer.setTeleportCommenceLocation(null);
return;
}
ItemStack inHand = player.getItemInHand();
ItemStack inHand = player.getInventory().getItemInMainHand();
if (!ItemUtils.isChimaeraWing(inHand) || inHand.getAmount() < Config.getInstance().getChimaeraUseCost()) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", LocaleLoader.getString("Item.ChimaeraWing.Name")));

View File

@@ -70,8 +70,8 @@ public class AbilityDisableTask extends BukkitRunnable {
int chunkX = chunk.getX();
int chunkZ = chunk.getZ();
for (int x = chunkX - radius; x < chunkX + radius; x++) {
for (int z = chunkZ - radius; z < chunkZ + radius; z++) {
for (int x = chunkX - radius; x <= chunkX + radius; x++) {
for (int z = chunkZ - radius; z <= chunkZ + radius; z++) {
world.refreshChunk(x, z);
}
}

View File

@@ -26,7 +26,7 @@ public class AlchemyBrewCheckTask extends BukkitRunnable {
public void run() {
Location location = brewingStand.getLocation();
ItemStack[] newInventory = Arrays.copyOfRange(brewingStand.getInventory().getContents(), 0, 4);
boolean validBrew = AlchemyPotionBrewer.isValidBrew(player, newInventory);
boolean validBrew = brewingStand.getFuelLevel() > 0 && AlchemyPotionBrewer.isValidBrew(player, newInventory);
if (Alchemy.brewingStandMap.containsKey(location)) {
if (oldInventory[Alchemy.INGREDIENT_SLOT] == null || newInventory[Alchemy.INGREDIENT_SLOT] == null || !oldInventory[Alchemy.INGREDIENT_SLOT].isSimilar(newInventory[Alchemy.INGREDIENT_SLOT]) || !validBrew) {

View File

@@ -27,6 +27,8 @@ public class AlchemyBrewTask extends BukkitRunnable {
private double brewSpeed;
private double brewTimer;
private Player player;
private int fuel;
private boolean firstRun = true;
public AlchemyBrewTask(BlockState brewingStand, Player player) {
this.brewingStand = brewingStand;
@@ -51,13 +53,18 @@ public class AlchemyBrewTask extends BukkitRunnable {
Alchemy.brewingStandMap.get(location).cancel();
}
fuel = ((BrewingStand) brewingStand).getFuelLevel();
if (((BrewingStand) brewingStand).getBrewingTime() == -1) // Only decrement on our end if it isn't a vanilla ingredient.
fuel--;
Alchemy.brewingStandMap.put(location, this);
this.runTaskTimer(mcMMO.p, 1, 1);
}
@Override
public void run() {
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND) {
if (player == null || !player.isValid() || brewingStand == null || brewingStand.getType() != Material.BREWING_STAND || !AlchemyPotionBrewer.isValidIngredient(player, ((BrewingStand) brewingStand).getInventory().getContents()[Alchemy.INGREDIENT_SLOT])) {
if (Alchemy.brewingStandMap.containsKey(location)) {
Alchemy.brewingStandMap.remove(location);
}
@@ -67,6 +74,11 @@ public class AlchemyBrewTask extends BukkitRunnable {
return;
}
if (firstRun) {
firstRun = false;
((BrewingStand) brewingStand).setFuelLevel(fuel);
}
brewTimer -= brewSpeed;
// Vanilla potion brewing completes when BrewingTime == 1

View File

@@ -1,15 +1,14 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Misc;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.Statistic;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.HolidayManager;
import com.gmail.nossr50.util.Misc;
public class AprilTask extends BukkitRunnable {
@Override
@@ -23,7 +22,7 @@ public class AprilTask extends BukkitRunnable {
int random = Misc.getRandom().nextInt(40) + 11;
int betterRandom = Misc.getRandom().nextInt(2000);
if (betterRandom == 0) {
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(unknown("superskill") + " skill increased by 1. Total (" + unknown("12") + ")");
fireworksShow(player);
}

View File

@@ -1,5 +1,7 @@
package com.gmail.nossr50.runnables.skills;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.World;
@@ -7,9 +9,6 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.Misc;
public class KrakenAttackTask extends BukkitRunnable {
private LivingEntity kraken;
private Player player;
@@ -86,11 +85,11 @@ public class KrakenAttackTask extends BukkitRunnable {
player.damage(AdvancedConfig.getInstance().getKrakenAttackDamage(), kraken);
if (GLOBAL_EFFECTS) {
world.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
world.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
world.strikeLightningEffect(playerLocation);
}
else {
player.playSound(playerLocation, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
player.playSound(playerLocation, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
world.createExplosion(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), 0F, false, false);
}
}

View File

@@ -137,7 +137,7 @@ public class AcrobaticsManager extends SkillManager {
Player player = getPlayer();
if (player.getItemInHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
if (player.getInventory().getItemInMainHand().getType() == Material.ENDER_PEARL || player.isInsideVehicle()) {
return true;
}

View File

@@ -38,16 +38,7 @@ public class AlchemyManager extends SkillManager {
StringBuilder list = new StringBuilder();
for (ItemStack ingredient : getIngredients()) {
short durability = ingredient.getDurability();
String string = StringUtils.getPrettyItemString(ingredient.getType()) + (durability != 0 ? ":" + durability : "");
if (string.equals("Long Grass:2")) {
string = "Fern";
}
else if (string.equals("Raw Fish:3")) {
string = "Pufferfish";
}
String string = StringUtils.getPrettyItemString(ingredient.getType());
list.append(", ").append(string);
}

View File

@@ -32,11 +32,11 @@ public final class AlchemyPotionBrewer {
}
for (int i = 0; i < 3; i++) {
if (contents[i] == null || contents[i].getType() != Material.POTION) {
if (contents[i] == null || contents[i].getType() != Material.POTION && contents[i].getType() != Material.SPLASH_POTION && contents[i].getType() != Material.LINGERING_POTION) {
continue;
}
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i].getDurability()), contents[Alchemy.INGREDIENT_SLOT]) != null) {
if (getChildPotion(PotionConfig.getInstance().getPotion(contents[i]), contents[Alchemy.INGREDIENT_SLOT]) != null) {
return true;
}
}
@@ -45,8 +45,8 @@ public final class AlchemyPotionBrewer {
}
private static AlchemyPotion getChildPotion(AlchemyPotion potion, ItemStack ingredient) {
if (potion != null && potion.getChildDataValue(ingredient) != -1) {
return PotionConfig.getInstance().getPotion(potion.getChildDataValue(ingredient));
if (potion != null) {
return potion.getChild(ingredient);
}
return null;
@@ -118,8 +118,8 @@ public final class AlchemyPotionBrewer {
continue;
}
AlchemyPotion input = PotionConfig.getInstance().getPotion(item.getDurability());
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
AlchemyPotion input = PotionConfig.getInstance().getPotion(item);
AlchemyPotion output = input.getChild(ingredient);
inputList.add(input);
@@ -128,7 +128,7 @@ public final class AlchemyPotionBrewer {
}
}
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory);
FakeBrewEvent event = new FakeBrewEvent(brewingStand.getBlock(), inventory, ((BrewingStand) brewingStand).getFuelLevel());
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled() || inputList.isEmpty()) {
@@ -138,7 +138,7 @@ public final class AlchemyPotionBrewer {
removeIngredient(inventory, player);
for (AlchemyPotion input : inputList) {
AlchemyPotion output = PotionConfig.getInstance().getPotion(input.getChildDataValue(ingredient));
AlchemyPotion output = input.getChild(ingredient);
if (output != null && player != null) {
PotionStage potionStage = PotionStage.getPotionStage(input, output);

View File

@@ -25,7 +25,7 @@ public class Axes {
protected static boolean hasArmor(LivingEntity target) {
for (ItemStack itemStack : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(itemStack)) {
if (itemStack != null && ItemUtils.isArmor(itemStack)) {
return true;
}
}

View File

@@ -103,7 +103,7 @@ public class AxesManager extends SkillManager {
int durabilityDamage = 1 + (getSkillLevel() / Axes.impactIncreaseLevel);
for (ItemStack armor : target.getEquipment().getArmorContents()) {
if (ItemUtils.isArmor(armor)) {
if (armor != null && ItemUtils.isArmor(armor)) {
if (SkillUtils.activationSuccessful(SecondaryAbility.ARMOR_IMPACT, getPlayer(), Axes.impactChance, activationChance)) {
SkillUtils.handleDurabilityChange(armor, durabilityDamage, Axes.impactMaxDurabilityModifier);
}

View File

@@ -16,7 +16,7 @@ public class ChildConfig extends AutoUpdateConfigLoader {
@Override
protected void loadKeys() {
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResource("child.yml")));
config.setDefaults(YamlConfiguration.loadConfiguration(plugin.getResourceAsReader("child.yml")));
FamilyTree.clearRegistrations(); // when reloading, need to clear statics

View File

@@ -1,16 +1,15 @@
package com.gmail.nossr50.skills.excavation;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.StringUtils;
import org.bukkit.block.BlockState;
import java.util.ArrayList;
import java.util.List;
public class Excavation {
/**
@@ -20,46 +19,14 @@ public class Excavation {
* @return the list of treasures that could be found
*/
protected static List<ExcavationTreasure> getTreasures(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
return blockState.getRawData() == 0x2 ? TreasureConfig.getInstance().excavationFromPodzol : TreasureConfig.getInstance().excavationFromDirt;
case GRASS:
return TreasureConfig.getInstance().excavationFromGrass;
case SAND:
return blockState.getRawData() == 0x1 ? TreasureConfig.getInstance().excavationFromRedSand : TreasureConfig.getInstance().excavationFromSand;
case GRAVEL:
return TreasureConfig.getInstance().excavationFromGravel;
case CLAY:
return TreasureConfig.getInstance().excavationFromClay;
case MYCEL:
return TreasureConfig.getInstance().excavationFromMycel;
case SOUL_SAND:
return TreasureConfig.getInstance().excavationFromSoulSand;
case SNOW:
return TreasureConfig.getInstance().excavationFromSnow;
default:
return new ArrayList<ExcavationTreasure>();
}
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (TreasureConfig.getInstance().excavationMap.containsKey(friendly))
return TreasureConfig.getInstance().excavationMap.get(friendly);
return new ArrayList<ExcavationTreasure>();
}
protected static int getBlockXP(BlockState blockState) {
Material material = blockState.getType();
int xp;
if (material == Material.DIRT || material == Material.SAND) {
xp = ExperienceConfig.getInstance().getDirtAndSandXp(blockState.getData());
}
else {
xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, material);
}
int xp = ExperienceConfig.getInstance().getXp(SkillType.EXCAVATION, blockState.getType());
if (xp == 0 && mcMMO.getModManager().isCustomExcavationBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();

View File

@@ -34,7 +34,7 @@ public class ExcavationManager extends SkillManager {
if (!treasures.isEmpty()) {
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
Location location = Misc.getBlockCenter(blockState);
for (ExcavationTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
@@ -57,6 +57,6 @@ public class ExcavationManager extends SkillManager {
excavationBlockCheck(blockState);
excavationBlockCheck(blockState);
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
}
}

View File

@@ -1,6 +1,5 @@
package com.gmail.nossr50.skills.fishing;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
@@ -8,6 +7,7 @@ import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.ItemStack;
@@ -15,18 +15,13 @@ import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.treasure.ShakeTreasure;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.adapter.BiomeAdapter;
public final class Fishing {
// The order of the values is extremely important, a few methods depend on it to work properly
public enum Tier {
EIGHT(8),
SEVEN(7),
SIX(6),
FIVE(5),
FOUR(4),
THREE(3),
TWO(2),
ONE(1);
EIGHT(8), SEVEN(7), SIX(6), FIVE(5), FOUR(4), THREE(3), TWO(2), ONE(1);
int numerical;
@@ -57,95 +52,30 @@ public final class Fishing {
public static int fishermansDietRankLevel2 = fishermansDietRankLevel1 * 2;
public static int fishermansDietMaxLevel = fishermansDietRankLevel1 * 5;
public static Set<Biome> masterAnglerBiomes = EnumSet.of(Biome.RIVER, Biome.OCEAN, Biome.DEEP_OCEAN);
public static Set<Biome> iceFishingBiomes = EnumSet.of(
Biome.FROZEN_OCEAN, Biome.FROZEN_RIVER,
Biome.TAIGA, Biome.TAIGA_HILLS, Biome.TAIGA_MOUNTAINS,
Biome.ICE_PLAINS, Biome.ICE_MOUNTAINS, Biome.ICE_PLAINS_SPIKES,
Biome.COLD_TAIGA, Biome.COLD_TAIGA_HILLS, Biome.COLD_TAIGA_MOUNTAINS);
public static Set<Biome> masterAnglerBiomes = BiomeAdapter.WATER_BIOMES;
public static Set<Biome> iceFishingBiomes = BiomeAdapter.ICE_BIOMES;
private Fishing() {}
/**
* Finds the possible drops of an entity
*
* @param target Targeted entity
* @param target
* Targeted entity
* @return possibleDrops List of ItemStack that can be dropped
*/
protected static List<ShakeTreasure> findPossibleDrops(LivingEntity target) {
switch (target.getType()) {
case BLAZE:
return TreasureConfig.getInstance().shakeFromBlaze;
if (TreasureConfig.getInstance().shakeMap.containsKey(target.getType()))
return TreasureConfig.getInstance().shakeMap.get(target.getType());
case CAVE_SPIDER:
return TreasureConfig.getInstance().shakeFromCaveSpider;
case CHICKEN:
return TreasureConfig.getInstance().shakeFromChicken;
case COW:
return TreasureConfig.getInstance().shakeFromCow;
case CREEPER:
return TreasureConfig.getInstance().shakeFromCreeper;
case ENDERMAN:
return TreasureConfig.getInstance().shakeFromEnderman;
case GHAST:
return TreasureConfig.getInstance().shakeFromGhast;
case IRON_GOLEM:
return TreasureConfig.getInstance().shakeFromIronGolem;
case MAGMA_CUBE:
return TreasureConfig.getInstance().shakeFromMagmaCube;
case MUSHROOM_COW:
return TreasureConfig.getInstance().shakeFromMushroomCow;
case PIG:
return TreasureConfig.getInstance().shakeFromPig;
case PIG_ZOMBIE:
return TreasureConfig.getInstance().shakeFromPigZombie;
case PLAYER:
return TreasureConfig.getInstance().shakeFromPlayer;
case SHEEP:
return TreasureConfig.getInstance().shakeFromSheep;
case SKELETON:
return TreasureConfig.getInstance().shakeFromSkeleton;
case SLIME:
return TreasureConfig.getInstance().shakeFromSlime;
case SNOWMAN:
return TreasureConfig.getInstance().shakeFromSnowman;
case SPIDER:
return TreasureConfig.getInstance().shakeFromSpider;
case SQUID:
return TreasureConfig.getInstance().shakeFromSquid;
case WITCH:
return TreasureConfig.getInstance().shakeFromWitch;
case ZOMBIE:
return TreasureConfig.getInstance().shakeFromZombie;
default:
return null;
}
return null;
}
/**
* Randomly chooses a drop among the list
*
* @param possibleDrops List of ItemStack that can be dropped
* @param possibleDrops
* List of ItemStack that can be dropped
* @return Chosen ItemStack
*/
protected static ItemStack chooseDrop(List<ShakeTreasure> possibleDrops) {

View File

@@ -1,42 +1,5 @@
package com.gmail.nossr50.skills.fishing;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.WeatherType;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.material.Wool;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import org.bukkit.util.Vector;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
@@ -53,16 +16,27 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerFishingTreasureEvent;
import com.gmail.nossr50.events.skills.fishing.McMMOPlayerShakeEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.KrakenAttackTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.fishing.Fishing.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionType;
import org.bukkit.util.Vector;
import java.util.*;
public class FishingManager extends SkillManager {
private final long FISHING_COOLDOWN_SECONDS = 1000L;
@@ -106,7 +80,7 @@ public class FishingManager extends SkillManager {
vehicle.remove();
}
player.teleport(player.getTargetBlock((HashSet<Byte>) null, 100).getLocation(), TeleportCause.PLUGIN);
player.teleport(player.getTargetBlock(null, 100).getLocation(), TeleportCause.PLUGIN);
String unleashMessage = AdvancedConfig.getInstance().getPlayerUnleashMessage();
@@ -122,7 +96,7 @@ public class FishingManager extends SkillManager {
world.strikeLightningEffect(location);
world.strikeLightningEffect(location);
world.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
world.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
mcMMO.p.getServer().broadcastMessage(ChatColor.RED + AdvancedConfig.getInstance().getServerUnleashMessage().replace("(PLAYER)", player.getDisplayName()));
}
else {
@@ -130,11 +104,14 @@ public class FishingManager extends SkillManager {
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
world.createExplosion(location.getX(), location.getY(), location.getZ(), 0F, false, false);
player.playSound(location, Sound.GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
player.playSound(location, Sound.ENTITY_GHAST_SCREAM, Misc.GHAST_VOLUME, Misc.getGhastPitch());
}
if (player.getItemInHand().getType() == Material.FISHING_ROD) {
player.setItemInHand(null);
if (player.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
player.getInventory().setItemInMainHand(null);
}
else if (player.getInventory().getItemInOffHand().getType() == Material.FISHING_ROD) {
player.getInventory().setItemInOffHand(null);
}
LivingEntity kraken = (LivingEntity) world.spawnEntity(player.getEyeLocation(), (Misc.getRandom().nextInt(100) == 0 ? EntityType.CHICKEN : EntityType.SQUID));
@@ -169,7 +146,7 @@ public class FishingManager extends SkillManager {
return false;
}
Block targetBlock = getPlayer().getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), 100);
Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
if (!targetBlock.isLiquid()) {
return false;
@@ -200,7 +177,7 @@ public class FishingManager extends SkillManager {
}
// Make sure this is a body of water, not just a block of ice.
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.STATIONARY_WATER)) {
if (!Fishing.iceFishingBiomes.contains(block.getBiome()) && (block.getRelative(BlockFace.DOWN, 3).getType() != Material.WATER)) {
return false;
}
@@ -259,16 +236,16 @@ public class FishingManager extends SkillManager {
return SkillUtils.handleFoodSkills(getPlayer(), skill, eventFoodLevel, Fishing.fishermansDietRankLevel1, Fishing.fishermansDietMaxLevel, rankChange);
}
public void iceFishing(Fish hook, Block block) {
public void iceFishing(FishHook hook, Block block) {
// Make a hole
block.setType(Material.STATIONARY_WATER);
block.setType(Material.WATER);
for (int x = -1; x <= 1; x++) {
for (int z = -1; z <= 1; z++) {
Block relative = block.getRelative(x, 0, z);
if (relative.getType() == Material.ICE) {
relative.setType(Material.STATIONARY_WATER);
relative.setType(Material.WATER);
}
}
}
@@ -277,7 +254,7 @@ public class FishingManager extends SkillManager {
EventUtils.callFakeFishEvent(getPlayer(), hook);
}
public void masterAngler(Fish hook) {
public void masterAngler(FishHook hook) {
Player player = getPlayer();
Location location = hook.getLocation();
double biteChance = hook.getBiteChance();
@@ -302,7 +279,7 @@ public class FishingManager extends SkillManager {
*/
public void handleFishing(Item fishingCatch) {
this.fishingCatch = fishingCatch;
int fishXp = ExperienceConfig.getInstance().getFishXp(fishingCatch.getItemStack().getData());
int fishXp = ExperienceConfig.getInstance().getXp(SkillType.FISHING, fishingCatch.getItemStack().getType());
int treasureXp = 0;
Player player = getPlayer();
FishingTreasure treasure = null;
@@ -400,14 +377,14 @@ public class FishingManager extends SkillManager {
Player targetPlayer = (Player) target;
switch (drop.getType()) {
case SKULL_ITEM:
case PLAYER_HEAD:
drop.setDurability((short) 3);
SkullMeta skullMeta = (SkullMeta) drop.getItemMeta();
skullMeta.setOwner(targetPlayer.getName());
skullMeta.setOwningPlayer(targetPlayer);
drop.setItemMeta(skullMeta);
break;
case BED_BLOCK:
case BEDROCK:
if (TreasureConfig.getInstance().getInventoryStealEnabled()) {
PlayerInventory inventory = targetPlayer.getInventory();
int length = inventory.getContents().length;
@@ -438,35 +415,15 @@ public class FishingManager extends SkillManager {
case SHEEP:
Sheep sheep = (Sheep) target;
if (drop.getType() == Material.WOOL) {
if (drop.getType().name().endsWith("WOOL")) {
if (sheep.isSheared()) {
return;
}
drop = new Wool(sheep.getColor()).toItemStack(drop.getAmount());
sheep.setSheared(true);
}
break;
case SKELETON:
if (((Skeleton) target).getSkeletonType() == SkeletonType.WITHER) {
switch (drop.getType()) {
case SKULL_ITEM:
drop.setDurability((short) 1);
break;
case ARROW:
drop.setType(Material.COAL);
break;
default:
break;
}
}
break;
default:
break;
break;
}
McMMOPlayerShakeEvent shakeEvent = new McMMOPlayerShakeEvent(getPlayer(), drop);
@@ -490,7 +447,18 @@ public class FishingManager extends SkillManager {
*/
private FishingTreasure getFishingTreasure() {
double diceRoll = Misc.getRandom().nextDouble() * 100;
diceRoll -= getPlayer().getItemInHand().getEnchantmentLevel(Enchantment.LUCK);
int luck;
if (getPlayer().getInventory().getItemInMainHand().getType() == Material.FISHING_ROD) {
luck = getPlayer().getInventory().getItemInMainHand().getEnchantmentLevel(Enchantment.LUCK);
}
else {
// We know something was caught, so if the rod wasn't in the main hand it must be in the offhand
luck = getPlayer().getInventory().getItemInOffHand().getEnchantmentLevel(Enchantment.LUCK);
}
// Rather than subtracting luck (and causing a minimum 3% chance for every drop), scale by luck.
diceRoll *= (1.0 - luck * Config.getInstance().getFishingLureModifier() / 100);
FishingTreasure treasure = null;
@@ -587,6 +555,11 @@ public class FishingManager extends SkillManager {
double dropRate = TreasureConfig.getInstance().getEnchantmentDropRate(getLootTier(), rarity);
if (diceRoll <= dropRate) {
// Make sure enchanted books always get some kind of enchantment. --hoorigan
if (treasureDrop.getType() == Material.ENCHANTED_BOOK) {
diceRoll = dropRate + 1;
continue;
}
fishingEnchantments = TreasureConfig.getInstance().fishingEnchantments.get(rarity);
break;
}
@@ -664,6 +637,6 @@ public class FishingManager extends SkillManager {
}
}
return 0;
return 1;
}
}

View File

@@ -1,16 +1,17 @@
package com.gmail.nossr50.skills.herbalism;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.util.skills.SkillUtils;
import java.util.HashSet;
public class Herbalism {
public static int farmersDietRankLevel1 = AdvancedConfig.getInstance().getFarmerDietRankChange();
public static int farmersDietRankLevel2 = farmersDietRankLevel1 * 2;
public static int farmersDietMaxLevel = farmersDietRankLevel1 * 5;
@@ -21,56 +22,129 @@ public class Herbalism {
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param blockState
* The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertGreenTerraBlocks(BlockState blockState) {
switch (blockState.getType()) {
case COBBLE_WALL:
blockState.setRawData((byte) 0x1);
case COBBLESTONE_WALL:
blockState.setType(Material.MOSSY_COBBLESTONE_WALL);
return true;
case SMOOTH_BRICK:
((SmoothBrick) blockState.getData()).setMaterial(Material.MOSSY_COBBLESTONE);
case STONE_BRICKS:
blockState.setType(Material.MOSSY_STONE_BRICKS);
return true;
case DIRT:
blockState.setType(Material.GRASS);
case DIRT :
case GRASS_PATH :
blockState.setType(Material.GRASS_BLOCK);
return true;
case COBBLESTONE:
case COBBLESTONE :
blockState.setType(Material.MOSSY_COBBLESTONE);
return true;
default:
default :
return false;
}
}
public static HashSet<Block> findChorusPlant(Block target) {
return findChorusPlant(target, new HashSet<Block>());
}
private static HashSet<Block> findChorusPlant(Block target, HashSet<Block> traversed) {
if (target.getType() != Material.CHORUS_PLANT) {
return traversed;
}
// Prevent any infinite loops, who needs more than 64 chorus anyways
if (traversed.size() > 64)
{
return traversed;
}
traversed.add(target);
Block relative = target.getRelative(BlockFace.UP, 1);
if (!traversed.contains(relative)) {
if (relative.getType() == Material.CHORUS_PLANT) {
traversed.addAll(findChorusPlant(relative, traversed));
}
}
relative = target.getRelative(BlockFace.NORTH, 1);
if (!traversed.contains(relative)) {
if (relative.getType() == Material.CHORUS_PLANT) {
traversed.addAll(findChorusPlant(relative, traversed));
}
}
relative = target.getRelative(BlockFace.SOUTH, 1);
if (!traversed.contains(relative)) {
if (relative.getType() == Material.CHORUS_PLANT) {
traversed.addAll(findChorusPlant(relative, traversed));
}
}
relative = target.getRelative(BlockFace.EAST, 1);
if (!traversed.contains(relative)) {
if (relative.getType() == Material.CHORUS_PLANT) {
traversed.addAll(findChorusPlant(relative, traversed));
}
}
relative = target.getRelative(BlockFace.WEST, 1);
if (!traversed.contains(relative)) {
if (relative.getType() == Material.CHORUS_PLANT) {
traversed.addAll(findChorusPlant(relative, traversed));
}
}
return traversed;
}
/**
* Calculate the drop amounts for cacti & sugar cane based on the blocks above them.
* Calculate the drop amounts for multi block plants based on the blocks
* relative to them.
*
* @param blockState The {@link BlockState} of the bottom block of the plant
* @param blockState
* The {@link BlockState} of the bottom block of the plant
* @return the number of bonus drops to award from the blocks in this plant
*/
protected static int calculateCatciAndSugarDrops(BlockState blockState) {
protected static int calculateMultiBlockPlantDrops(BlockState blockState) {
Block block = blockState.getBlock();
Material blockType = blockState.getType();
int dropAmount = mcMMO.getPlaceStore().isTrue(block) ? 0 : 1;
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 3; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
if (blockType == Material.CHORUS_PLANT) {
dropAmount = 1;
if (relativeBlock.getType() != blockType) {
break;
}
if (block.getRelative(BlockFace.DOWN, 1).getType() == Material.END_STONE) {
HashSet<Block> blocks = findChorusPlant(block);
if (mcMMO.getPlaceStore().isTrue(relativeBlock)) {
mcMMO.getPlaceStore().setFalse(relativeBlock);
dropAmount = blocks.size();
/*
* for(Block b : blocks) {
* b.breakNaturally();
* }
*/
}
else {
dropAmount++;
} else {
// Handle the two blocks above it - cacti & sugar cane can only grow 3 high naturally
for (int y = 1; y < 3; y++) {
Block relativeBlock = block.getRelative(BlockFace.UP, y);
if (relativeBlock.getType() != blockType) {
break;
}
if (mcMMO.getPlaceStore().isTrue(relativeBlock)) {
mcMMO.getPlaceStore().setFalse(relativeBlock);
} else {
dropAmount++;
}
}
}
@@ -80,17 +154,19 @@ public class Herbalism {
/**
* Convert blocks affected by the Green Thumb & Green Terra abilities.
*
* @param blockState The {@link BlockState} to check ability activation for
* @param blockState
* The {@link BlockState} to check ability activation for
* @return true if the ability was successful, false otherwise
*/
protected static boolean convertShroomThumb(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
case GRASS:
blockState.setType(Material.MYCEL);
case DIRT :
case GRASS_BLOCK:
case GRASS_PATH :
blockState.setType(Material.MYCELIUM);
return true;
default:
default :
return false;
}
}
@@ -98,7 +174,8 @@ public class Herbalism {
/**
* Check if the block has a recently grown crop from Green Thumb
*
* @param blockState The {@link BlockState} to check green thumb regrown for
* @param blockState
* The {@link BlockState} to check green thumb regrown for
* @return true if the block is recently regrown, false otherwise
*/
public static boolean isRecentlyRegrown(BlockState blockState) {

View File

@@ -1,43 +1,29 @@
package com.gmail.nossr50.skills.herbalism;
import java.util.Collection;
import java.util.List;
import org.bukkit.CropState;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.NetherWartsState;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.Crops;
import org.bukkit.material.NetherWarts;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.treasure.TreasureConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.datatypes.skills.*;
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.HerbalismBlockUpdaterTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.metadata.FixedMetadataValue;
import java.util.Collection;
import java.util.List;
public class HerbalismManager extends SkillManager {
public HerbalismManager(McMMOPlayer mcMMOPlayer) {
@@ -50,15 +36,17 @@ public class HerbalismManager extends SkillManager {
public boolean canGreenThumbBlock(BlockState blockState) {
Player player = getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
return player.getItemInHand().getType() == Material.SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
return item.getAmount() > 0 && item.getType() == Material.WHEAT_SEEDS && BlockUtils.canMakeMossy(blockState) && Permissions.greenThumbBlock(player, blockState.getType());
}
public boolean canUseShroomThumb(BlockState blockState) {
Player player = getPlayer();
Material itemType = player.getItemInHand().getType();
PlayerInventory inventory = player.getInventory();
Material itemType = inventory.getItemInMainHand().getType();
return (itemType == Material.RED_MUSHROOM || itemType == Material.BROWN_MUSHROOM) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
return (itemType == Material.BROWN_MUSHROOM || itemType == Material.RED_MUSHROOM) && inventory.contains(Material.BROWN_MUSHROOM, 1) && inventory.contains(Material.RED_MUSHROOM, 1) && BlockUtils.canMakeShroomy(blockState) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.SHROOM_THUMB);
}
public boolean canUseHylianLuck() {
@@ -102,7 +90,7 @@ public class HerbalismManager extends SkillManager {
}
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = new ItemStack(Material.SEEDS);
ItemStack seed = new ItemStack(Material.WHEAT_SEEDS);
if (!playerInventory.containsAtLeast(seed, 1)) {
player.sendMessage(LocaleLoader.getString("Herbalism.Ability.GTe.NeedMore"));
@@ -121,8 +109,9 @@ public class HerbalismManager extends SkillManager {
public void herbalismBlockCheck(BlockState blockState) {
Player player = getPlayer();
Material material = blockState.getType();
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.SUGAR_CANE_BLOCK);
boolean oneBlockPlant = !(material == Material.CACTUS || material == Material.CHORUS_PLANT || material == Material.SUGAR_CANE);
// Prevents placing and immediately breaking blocks for exp
if (oneBlockPlant && mcMMO.getPlaceStore().isTrue(blockState)) {
return;
}
@@ -145,25 +134,20 @@ public class HerbalismManager extends SkillManager {
}
}
else {
if (Permissions.greenThumbPlant(player, material)) {
processGreenThumbPlants(blockState, greenTerra);
}
if (material == Material.DOUBLE_PLANT || material == Material.RED_ROSE || material == Material.LONG_GRASS) {
xp = ExperienceConfig.getInstance().getFlowerAndGrassXp(blockState.getData());
}
else {
xp = ExperienceConfig.getInstance().getXp(skill, material);
}
xp = ExperienceConfig.getInstance().getXp(skill, blockState.getBlockData());
if (Config.getInstance().getDoubleDropsEnabled(skill, material) && Permissions.secondaryAbilityEnabled(player, SecondaryAbility.HERBALISM_DOUBLE_DROPS)) {
drops = blockState.getBlock().getDrops();
}
if (!oneBlockPlant) {
amount = Herbalism.calculateCatciAndSugarDrops(blockState);
amount = Herbalism.calculateMultiBlockPlantDrops(blockState);
xp *= amount;
}
if (Permissions.greenThumbPlant(player, material)) {
processGreenThumbPlants(blockState, greenTerra);
}
}
applyXpGain(xp, XPGainReason.PVE);
@@ -175,7 +159,7 @@ public class HerbalismManager extends SkillManager {
for (int i = greenTerra ? 2 : 1; i != 0; i--) {
if (SkillUtils.activationSuccessful(SecondaryAbility.HERBALISM_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
for (ItemStack item : drops) {
Misc.dropItems(blockState.getLocation(), item, amount);
Misc.dropItems(Misc.getBlockCenter(blockState), item, amount);
}
}
}
@@ -207,32 +191,10 @@ public class HerbalismManager extends SkillManager {
return false;
}
List<HylianTreasure> treasures;
switch (blockState.getType()) {
case DEAD_BUSH:
case LONG_GRASS:
case SAPLING:
treasures = TreasureConfig.getInstance().hylianFromBushes;
break;
case RED_ROSE:
case YELLOW_FLOWER:
if (mcMMO.getPlaceStore().isTrue(blockState)) {
mcMMO.getPlaceStore().setFalse(blockState);
return false;
}
treasures = TreasureConfig.getInstance().hylianFromFlowers;
break;
case FLOWER_POT:
treasures = TreasureConfig.getInstance().hylianFromPots;
break;
default:
return false;
}
String friendly = StringUtils.getFriendlyConfigBlockDataString(blockState.getBlockData());
if (!TreasureConfig.getInstance().hylianMap.containsKey(friendly))
return false;
List<HylianTreasure> treasures = TreasureConfig.getInstance().hylianMap.get(friendly);
Player player = getPlayer();
@@ -240,7 +202,7 @@ public class HerbalismManager extends SkillManager {
return false;
}
int skillLevel = getSkillLevel();
Location location = blockState.getLocation();
Location location = Misc.getBlockCenter(blockState);
for (HylianTreasure treasure : treasures) {
if (skillLevel >= treasure.getDropLevel() && SkillUtils.treasureDropSuccessful(getPlayer(), treasure.getDropChance(), activationChance)) {
@@ -265,13 +227,13 @@ public class HerbalismManager extends SkillManager {
public boolean processShroomThumb(BlockState blockState) {
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
if (!playerInventory.contains(Material.BROWN_MUSHROOM)) {
if (!playerInventory.contains(Material.BROWN_MUSHROOM, 1)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.BROWN_MUSHROOM)));
return false;
}
if (!playerInventory.contains(Material.RED_MUSHROOM)) {
if (!playerInventory.contains(Material.RED_MUSHROOM, 1)) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(Material.RED_MUSHROOM)));
return false;
}
@@ -295,32 +257,45 @@ public class HerbalismManager extends SkillManager {
* @param greenTerra boolean to determine if greenTerra is active or not
*/
private void processGreenThumbPlants(BlockState blockState, boolean greenTerra) {
if (!BlockUtils.isFullyGrown(blockState))
return;
Player player = getPlayer();
PlayerInventory playerInventory = player.getInventory();
ItemStack seed = null;
Material seed = null;
switch (blockState.getType()) {
case CARROT:
seed = new ItemStack(Material.CARROT_ITEM);
case CARROTS:
seed = Material.CARROT;
break;
case CROPS:
seed = new ItemStack(Material.SEEDS);
case WHEAT:
seed = Material.WHEAT_SEEDS;
break;
case NETHER_WARTS:
seed = new ItemStack(Material.NETHER_STALK);
case NETHER_WART:
seed = Material.NETHER_WART;
break;
case POTATO:
seed = new ItemStack(Material.POTATO_ITEM);
case POTATOES:
seed = Material.POTATO;
break;
case BEETROOTS:
seed = Material.BEETROOT_SEEDS;
break;
case COCOA:
seed = Material.COCOA_BEANS;
break;
default:
break;
return;
}
if (!playerInventory.containsAtLeast(seed, 1)) {
ItemStack seedStack = new ItemStack(seed);
if (!playerInventory.containsAtLeast(seedStack, 1)) {
return;
}
@@ -332,7 +307,7 @@ public class HerbalismManager extends SkillManager {
return;
}
playerInventory.removeItem(seed);
playerInventory.removeItem(seedStack);
player.updateInventory(); // Needed until replacement available
new HerbalismBlockUpdaterTask(blockState).runTaskLater(mcMMO.p, 0);
}
@@ -341,74 +316,51 @@ public class HerbalismManager extends SkillManager {
byte greenThumbStage = getGreenThumbStage();
blockState.setMetadata(mcMMO.greenThumbDataKey, new FixedMetadataValue(mcMMO.p, (int) (System.currentTimeMillis() / Misc.TIME_CONVERSION_FACTOR)));
Ageable crops = (Ageable) blockState.getBlockData();
switch (blockState.getType()) {
case CROPS:
Crops crops = (Crops) blockState.getData();
case POTATOES:
case CARROTS:
case WHEAT:
if (greenTerra) {
crops.setState(CropState.MEDIUM);
crops.setAge(3);
}
else {
switch (greenThumbStage) {
case 4:
crops.setState(CropState.SMALL);
break;
case 3:
crops.setState(CropState.VERY_SMALL);
break;
case 2:
crops.setState(CropState.GERMINATED);
break;
default:
crops.setState(CropState.SEEDED);
break;
}
crops.setAge(greenThumbStage);
}
break;
return true;
case CARROT:
case POTATO:
if (greenTerra) {
blockState.setRawData(CropState.MEDIUM.getData());
}
else {
blockState.setRawData(greenThumbStage);
}
return true;
case NETHER_WARTS:
NetherWarts warts = (NetherWarts) blockState.getData();
case BEETROOTS:
case NETHER_WART:
if (greenTerra || greenThumbStage > 2) {
warts.setState(NetherWartsState.STAGE_TWO);
crops.setAge(2);
}
else if (greenThumbStage == 2) {
warts.setState(NetherWartsState.STAGE_ONE);
crops.setAge(1);
}
else {
warts.setState(NetherWartsState.SEEDED);
crops.setAge(0);
}
return true;
break;
case COCOA:
CocoaPlant plant = (CocoaPlant) blockState.getData();
if (greenTerra || getGreenThumbStage() > 1) {
plant.setSize(CocoaPlantSize.MEDIUM);
crops.setAge(1);
}
else {
plant.setSize(CocoaPlantSize.SMALL);
crops.setAge(0);
}
return true;
break;
default:
return false;
}
blockState.setBlockData(crops);
return true;
}
private byte getGreenThumbStage() {

View File

@@ -1,15 +1,13 @@
package com.gmail.nossr50.skills.mining;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.Misc;
public class Mining {
/**
@@ -18,8 +16,7 @@ public class Mining {
* @param blockState The {@link BlockState} to check ability activation for
*/
public static int getBlockXp(BlockState blockState) {
Material blockType = blockState.getType();
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockType != Material.GLOWING_REDSTONE_ORE ? blockType : Material.REDSTONE_ORE);
int xp = ExperienceConfig.getInstance().getXp(SkillType.MINING, blockState.getType());
if (xp == 0 && mcMMO.getModManager().isCustomMiningBlock(blockState)) {
xp = mcMMO.getModManager().getBlock(blockState).getXpGain();
@@ -37,40 +34,65 @@ public class Mining {
Material blockType = blockState.getType();
switch (blockType) {
case ENDER_STONE:
case GOLD_ORE:
case HARD_CLAY:
case END_STONE:
case TERRACOTTA:
case CLAY:
case IRON_ORE:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case SANDSTONE:
case STAINED_CLAY:
case BLACK_GLAZED_TERRACOTTA:
case BLACK_TERRACOTTA:
case BLUE_GLAZED_TERRACOTTA:
case BLUE_TERRACOTTA:
case BROWN_GLAZED_TERRACOTTA:
case BROWN_TERRACOTTA:
case CYAN_GLAZED_TERRACOTTA:
case CYAN_TERRACOTTA:
case GRAY_GLAZED_TERRACOTTA:
case GRAY_TERRACOTTA:
case GREEN_GLAZED_TERRACOTTA:
case GREEN_TERRACOTTA:
case LIGHT_BLUE_GLAZED_TERRACOTTA:
case LIGHT_BLUE_TERRACOTTA:
case LIGHT_GRAY_GLAZED_TERRACOTTA:
case LIGHT_GRAY_TERRACOTTA:
case LIME_GLAZED_TERRACOTTA:
case LIME_TERRACOTTA:
case MAGENTA_GLAZED_TERRACOTTA:
case MAGENTA_TERRACOTTA:
case ORANGE_GLAZED_TERRACOTTA:
case ORANGE_TERRACOTTA:
case PINK_GLAZED_TERRACOTTA:
case PINK_TERRACOTTA:
case PURPLE_GLAZED_TERRACOTTA:
case PURPLE_TERRACOTTA:
case RED_GLAZED_TERRACOTTA:
case RED_TERRACOTTA:
case WHITE_GLAZED_TERRACOTTA:
case WHITE_TERRACOTTA:
case YELLOW_GLAZED_TERRACOTTA:
case YELLOW_TERRACOTTA:
handleMiningDrops(blockState);
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItem(blockState.getLocation(), new ItemStack(Material.REDSTONE_ORE));
}
return;
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
case GLOWSTONE:
case LAPIS_ORE:
case PACKED_ICE:
case QUARTZ_ORE:
case NETHER_QUARTZ_ORE:
case REDSTONE_ORE:
case STONE:
case PRISMARINE:
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
return;
default:
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1));
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType()));
}
return;
}
@@ -86,10 +108,10 @@ public class Mining {
case COAL_ORE:
case DIAMOND_ORE:
case EMERALD_ORE:
case ENDER_STONE:
case END_STONE:
case GLOWSTONE:
case GOLD_ORE:
case HARD_CLAY:
case TERRACOTTA:
case IRON_ORE:
case LAPIS_ORE:
case MOSSY_COBBLESTONE:
@@ -98,21 +120,46 @@ public class Mining {
case PACKED_ICE:
case REDSTONE_ORE:
case SANDSTONE:
case STAINED_CLAY:
case BLACK_GLAZED_TERRACOTTA:
case BLACK_TERRACOTTA:
case BLUE_GLAZED_TERRACOTTA:
case BLUE_TERRACOTTA:
case BROWN_GLAZED_TERRACOTTA:
case BROWN_TERRACOTTA:
case CYAN_GLAZED_TERRACOTTA:
case CYAN_TERRACOTTA:
case GRAY_GLAZED_TERRACOTTA:
case GRAY_TERRACOTTA:
case GREEN_GLAZED_TERRACOTTA:
case GREEN_TERRACOTTA:
case LIGHT_BLUE_GLAZED_TERRACOTTA:
case LIGHT_BLUE_TERRACOTTA:
case LIGHT_GRAY_GLAZED_TERRACOTTA:
case LIGHT_GRAY_TERRACOTTA:
case LIME_GLAZED_TERRACOTTA:
case LIME_TERRACOTTA:
case MAGENTA_GLAZED_TERRACOTTA:
case MAGENTA_TERRACOTTA:
case ORANGE_GLAZED_TERRACOTTA:
case ORANGE_TERRACOTTA:
case PINK_GLAZED_TERRACOTTA:
case PINK_TERRACOTTA:
case PURPLE_GLAZED_TERRACOTTA:
case PURPLE_TERRACOTTA:
case RED_GLAZED_TERRACOTTA:
case RED_TERRACOTTA:
case WHITE_GLAZED_TERRACOTTA:
case WHITE_TERRACOTTA:
case YELLOW_GLAZED_TERRACOTTA:
case YELLOW_TERRACOTTA:
case STONE:
case QUARTZ_ORE:
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
return;
case GLOWING_REDSTONE_ORE:
if (Config.getInstance().getDoubleDropsEnabled(SkillType.MINING, Material.REDSTONE_ORE)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
}
case NETHER_QUARTZ_ORE:
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
return;
default:
if (mcMMO.getModManager().isCustomMiningBlock(blockState)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
return;
}

View File

@@ -1,17 +1,5 @@
package com.gmail.nossr50.skills.mining;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@@ -19,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.AbilityCooldownTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.BlastMining.Tier;
@@ -27,6 +16,16 @@ import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.List;
public class MiningManager extends SkillManager {
public MiningManager(McMMOPlayer mcMMOPlayer) {
@@ -40,7 +39,7 @@ public class MiningManager extends SkillManager {
public boolean canDetonate() {
Player player = getPlayer();
return canUseBlastMining() && player.isSneaking() && player.getItemInHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player);
return canUseBlastMining() && player.isSneaking() && player.getInventory().getItemInMainHand().getType() == BlastMining.detonator && Permissions.remoteDetonation(player);
}
public boolean canUseBlastMining() {
@@ -68,14 +67,14 @@ public class MiningManager extends SkillManager {
Material material = blockState.getType();
if (mcMMOPlayer.getAbilityMode(skill.getAbility())) {
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
}
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || material != Material.GLOWING_REDSTONE_ORE && !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
if ((mcMMO.getModManager().isCustomMiningBlock(blockState) && !mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) || !Config.getInstance().getDoubleDropsEnabled(skill, material)) {
return;
}
boolean silkTouch = player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH);
boolean silkTouch = player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH);
for (int i = mcMMOPlayer.getAbilityMode(skill.getAbility()) ? 2 : 1; i != 0; i--) {
if (SkillUtils.activationSuccessful(SecondaryAbility.MINING_DOUBLE_DROPS, getPlayer(), getSkillLevel(), activationChance)) {
@@ -94,7 +93,7 @@ public class MiningManager extends SkillManager {
*/
public void remoteDetonation() {
Player player = getPlayer();
Block targetBlock = player.getTargetBlock((HashSet<Byte>) BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
@@ -148,7 +147,7 @@ public class MiningManager extends SkillManager {
xp += Mining.getBlockXp(blockState);
}
Misc.dropItem(blockState.getLocation(), blockState.getData().toItemStack(1)); // Initial block that would have been dropped
Misc.dropItem(Misc.getBlockCenter(blockState), new ItemStack(blockState.getType())); // Initial block that would have been dropped
if (!mcMMO.getPlaceStore().isTrue(blockState)) {
for (int i = 1; i < dropMultiplier; i++) {
@@ -161,7 +160,7 @@ public class MiningManager extends SkillManager {
if (debrisYield > 0) {
for (BlockState blockState : debris) {
if (Misc.getRandom().nextFloat() < debrisYield) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
}
}

View File

@@ -1,17 +1,5 @@
package com.gmail.nossr50.skills.repair;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
@@ -19,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
@@ -27,6 +16,16 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.block.data.BlockData;
import java.util.Map;
import java.util.Map.Entry;
public class RepairManager extends SkillManager {
private boolean placedAnvil;
@@ -51,7 +50,7 @@ public class RepairManager extends SkillManager {
}
if (Config.getInstance().getRepairAnvilPlaceSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
}
togglePlacedAnvil();
@@ -61,6 +60,11 @@ public class RepairManager extends SkillManager {
Player player = getPlayer();
Repairable repairable = mcMMO.getRepairableManager().getRepairable(item.getType());
if (item.getItemMeta().isUnbreakable()) {
player.sendMessage(LocaleLoader.getString("Anvil.Unbreakable"));
return;
}
// Permissions checks on material and item types
if (!Permissions.repairMaterialType(player, repairable.getRepairMaterialType())) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
@@ -85,7 +89,7 @@ public class RepairManager extends SkillManager {
Material repairMaterial = repairable.getRepairMaterial();
byte repairMaterialMetadata = repairable.getRepairMaterialMetadata();
ItemStack toRemove = new MaterialData(repairMaterial, repairMaterialMetadata).toItemStack(1);
ItemStack toRemove = new ItemStack(repairMaterial);
short startDurability = item.getDurability();
@@ -145,7 +149,7 @@ public class RepairManager extends SkillManager {
// BWONG BWONG BWONG
if (Config.getInstance().getRepairAnvilUseSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
}
// Repair the item!

View File

@@ -1,8 +1,18 @@
package com.gmail.nossr50.skills.salvage;
import java.util.Map;
import java.util.Map.Entry;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.Salvage.Tier;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@@ -10,20 +20,10 @@ import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.block.data.BlockData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.salvage.Salvage.Tier;
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import java.util.Map;
import java.util.Map.Entry;
public class SalvageManager extends SkillManager {
private boolean placedAnvil;
@@ -48,7 +48,7 @@ public class SalvageManager extends SkillManager {
}
if (Config.getInstance().getSalvageAnvilPlaceSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_LAND, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
}
togglePlacedAnvil();
@@ -59,6 +59,11 @@ public class SalvageManager extends SkillManager {
Salvageable salvageable = mcMMO.getSalvageableManager().getSalvageable(item.getType());
if (item.getItemMeta().isUnbreakable()) {
player.sendMessage(LocaleLoader.getString("Anvil.Unbreakable"));
return;
}
// Permissions checks on material and item types
if (!Permissions.salvageItemType(player, salvageable.getSalvageItemType())) {
player.sendMessage(LocaleLoader.getString("mcMMO.NoPermission"));
@@ -93,27 +98,33 @@ public class SalvageManager extends SkillManager {
salvageableAmount = Math.max((int) (salvageableAmount * getMaxSalvagePercentage()), 1); // Always get at least something back, if you're capable of salvaging it.
player.setItemInHand(new ItemStack(Material.AIR));
location.add(0, 1, 0);
player.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
location.add(0.5, 1, 0.5);
Map<Enchantment, Integer> enchants = item.getEnchantments();
ItemStack enchantBook = null;
if (!enchants.isEmpty()) {
ItemStack enchantBook = arcaneSalvageCheck(enchants);
if (enchantBook != null) {
Misc.dropItem(location, enchantBook);
}
enchantBook = arcaneSalvageCheck(enchants);
}
byte salvageMaterialMetadata = (salvageable.getSalvageMaterialMetadata() != (byte) -1) ? salvageable.getSalvageMaterialMetadata() : 0;
ItemStack salvageResults = new ItemStack(salvageable.getSalvageMaterial(), salvageableAmount);
Misc.dropItems(location, new MaterialData(salvageable.getSalvageMaterial(), salvageMaterialMetadata).toItemStack(salvageableAmount), 1);
//Call event
if (EventUtils.callSalvageCheckEvent(player, item, salvageResults, enchantBook).isCancelled()) {
return;
}
if (enchantBook != null) {
Misc.dropItem(location, enchantBook);
}
Misc.dropItems(location, salvageResults, 1);
// BWONG BWONG BWONG - CLUNK!
if (Config.getInstance().getSalvageAnvilUseSoundsEnabled()) {
player.playSound(player.getLocation(), Sound.ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
player.playSound(player.getLocation(), Sound.BLOCK_ANVIL_USE, Misc.ANVIL_USE_VOLUME, Misc.ANVIL_USE_PITCH);
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1.0F, 1.0F);
}
player.sendMessage(LocaleLoader.getString("Salvage.Skills.Success"));

View File

@@ -1,13 +1,10 @@
package com.gmail.nossr50.skills.smelting;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import org.bukkit.inventory.ItemStack;
public class Smelting {
// The order of the values is extremely important, a few methods depend on it to work properly
@@ -23,7 +20,7 @@ public class Smelting {
int numerical;
private Tier(int numerical) {
Tier(int numerical) {
this.numerical = numerical;
}
@@ -47,9 +44,6 @@ public class Smelting {
public static double fluxMiningChance = AdvancedConfig.getInstance().getFluxMiningChance();
protected static int getResourceXp(ItemStack smelting) {
MaterialData data = smelting.getData();
Material resourceType = smelting.getType();
return mcMMO.getModManager().isCustomOre(data) ? mcMMO.getModManager().getBlock(data).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, resourceType != Material.GLOWING_REDSTONE_ORE ? resourceType : Material.REDSTONE_ORE);
return mcMMO.getModManager().isCustomOre(smelting.getType()) ? mcMMO.getModManager().getBlock(smelting.getType()).getSmeltingXpGain() : ExperienceConfig.getInstance().getXp(SkillType.SMELTING, smelting.getType());
}
}

View File

@@ -1,8 +1,22 @@
package com.gmail.nossr50.skills.smelting;
import java.util.ArrayList;
import java.util.List;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@@ -13,23 +27,8 @@ import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.mining.Mining;
import com.gmail.nossr50.skills.smelting.Smelting.Tier;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import java.util.ArrayList;
import java.util.List;
public class SmeltingManager extends SkillManager {
public SmeltingManager(McMMOPlayer mcMMOPlayer) {
@@ -82,14 +81,14 @@ public class SmeltingManager extends SkillManager {
// We need to distribute Mining XP here, because the block break event gets cancelled
applyXpGain(Mining.getBlockXp(blockState), XPGainReason.PVE);
SkillUtils.handleDurabilityChange(getPlayer().getItemInHand(), Config.getInstance().getAbilityToolDamage());
SkillUtils.handleDurabilityChange(getPlayer().getInventory().getItemInMainHand(), Config.getInstance().getAbilityToolDamage());
Misc.dropItems(blockState.getLocation(), item, isSecondSmeltSuccessful() ? 2 : 1);
Misc.dropItems(Misc.getBlockCenter(blockState), item, isSecondSmeltSuccessful() ? 2 : 1);
blockState.setType(Material.AIR);
if (Config.getInstance().getFluxPickaxeSoundEnabled()) {
player.playSound(blockState.getLocation(), Sound.FIZZ, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
player.playSound(blockState.getLocation(), Sound.BLOCK_FIRE_EXTINGUISH, Misc.FIZZ_VOLUME, Misc.getFizzPitch());
}
ParticleEffectUtils.playFluxEffect(blockState.getLocation());

View File

@@ -30,10 +30,6 @@ public class Taming {
public static int thickFurUnlockLevel = AdvancedConfig.getInstance().getThickFurUnlock();
public static double thickFurModifier = AdvancedConfig.getInstance().getThickFurModifier();
public static int wolfXp = ExperienceConfig.getInstance().getTamingXPWolf();
public static int ocelotXp = ExperienceConfig.getInstance().getTamingXPOcelot();
public static int horseXp = ExperienceConfig.getInstance().getTamingXPHorse();
public static boolean canPreventDamage(Tameable pet, AnimalTamer owner) {
return pet.isTamed() && owner instanceof Player && pet instanceof Wolf;
}

View File

@@ -1,24 +1,8 @@
package com.gmail.nossr50.skills.taming;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Player;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.Wolf;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
@@ -26,6 +10,7 @@ import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.events.fake.FakeEntityTameEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityWeightedActivationCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.skills.BleedTimerTask;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.Misc;
@@ -34,6 +19,14 @@ import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.*;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class TamingManager extends SkillManager {
public TamingManager(McMMOPlayer mcMMOPlayer) {
@@ -47,7 +40,7 @@ public class TamingManager extends SkillManager {
}
public boolean canUseEnvironmentallyAware() {
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ENVIROMENTALLY_AWARE);
return getSkillLevel() >= Taming.environmentallyAwareUnlockLevel && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.ENVIRONMENTALLY_AWARE);
}
public boolean canUseShockProof() {
@@ -80,22 +73,7 @@ public class TamingManager extends SkillManager {
* @param entity The LivingEntity to award XP for
*/
public void awardTamingXP(LivingEntity entity) {
switch (entity.getType()) {
case HORSE:
applyXpGain(Taming.horseXp, XPGainReason.PVE);
return;
case WOLF:
applyXpGain(Taming.wolfXp, XPGainReason.PVE);
return;
case OCELOT:
applyXpGain(Taming.ocelotXp, XPGainReason.PVE);
return;
default:
return;
}
applyXpGain(ExperienceConfig.getInstance().getTamingXP(entity.getType()), XPGainReason.PVE);
}
/**
@@ -132,7 +110,7 @@ public class TamingManager extends SkillManager {
BleedTimerTask.add(target, Taming.goreBleedTicks);
if (target instanceof Player) {
((Player) target).sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
target.sendMessage(LocaleLoader.getString("Combat.StruckByGore"));
}
getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore"));
@@ -256,7 +234,7 @@ public class TamingManager extends SkillManager {
private void callOfTheWild(EntityType type, int summonAmount) {
Player player = getPlayer();
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
int heldItemAmount = heldItem.getAmount();
Location location = player.getLocation();
@@ -325,7 +303,9 @@ public class TamingManager extends SkillManager {
ParticleEffectUtils.playCallOfTheWildEffect(entity);
}
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
ItemStack leftovers = new ItemStack(heldItem);
leftovers.setAmount(heldItemAmount - summonAmount);
player.getInventory().setItemInMainHand(heldItemAmount == summonAmount ? null : leftovers);
String lifeSpan = "";
if (tamingCOTWLength > 0) {
@@ -333,7 +313,7 @@ public class TamingManager extends SkillManager {
}
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete") + lifeSpan);
player.playSound(location, Sound.FIREWORK_LARGE_BLAST2, 1F, 0.5F);
player.playSound(location, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 1F, 0.5F);
}
private boolean rangeCheck(EntityType type) {

View File

@@ -1,18 +1,17 @@
package com.gmail.nossr50.skills.taming;
import java.util.UUID;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.scheduler.BukkitRunnable;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import java.util.UUID;
public class TrackedTamingEntity extends BukkitRunnable {
private LivingEntity livingEntity;
@@ -35,7 +34,7 @@ public class TrackedTamingEntity extends BukkitRunnable {
public void run() {
if (livingEntity.isValid()) {
Location location = livingEntity.getLocation();
location.getWorld().playSound(location, Sound.FIZZ, 0.8F, 0.8F);
location.getWorld().playSound(location, Sound.BLOCK_FIRE_EXTINGUISH, 0.8F, 0.8F);
ParticleEffectUtils.playCallOfTheWildEffect(livingEntity);
CombatUtils.dealDamage(livingEntity, livingEntity.getMaxHealth(), DamageCause.SUICIDE, livingEntity);
}

View File

@@ -26,7 +26,8 @@ public class Unarmed {
if (inventory.containsAtLeast(dropStack, 1)) {
int nextSlot = 0;
for (ItemStack itemstack : inventory) {
ItemStack[] items = inventory.getStorageContents();
for (ItemStack itemstack : items) {
if (dropStack.isSimilar(itemstack)) {
int itemAmount = itemstack.getAmount();
int itemMax = itemstack.getMaxStackSize();
@@ -36,13 +37,15 @@ public class Unarmed {
if (dropAmount + itemAmount <= itemMax) {
drop.remove();
addStack.setAmount(dropAmount + itemAmount);
inventory.setItem(nextSlot, addStack);
items[nextSlot] = addStack;
inventory.setStorageContents(items);
return true;
}
addStack.setAmount(itemMax);
dropAmount = dropAmount + itemAmount - itemMax;
inventory.setItem(nextSlot, addStack);
items[nextSlot] = addStack;
inventory.setStorageContents(items);
}
if (dropAmount == 0) {
@@ -57,13 +60,15 @@ public class Unarmed {
if (firstEmpty == inventory.getHeldItemSlot()) {
int nextSlot = firstEmpty + 1;
for (Iterator<ItemStack> iterator = inventory.iterator(nextSlot); iterator.hasNext(); ) {
ItemStack itemstack = iterator.next();
ItemStack[] items = inventory.getStorageContents();
for (; nextSlot < items.length; nextSlot++) {
ItemStack itemstack = items[nextSlot];
if (itemstack == null) {
drop.remove();
dropStack.setAmount(dropAmount);
inventory.setItem(nextSlot, dropStack);
items[nextSlot] = dropStack;
inventory.setStorageContents(items);
return true;
}

View File

@@ -1,15 +1,5 @@
package com.gmail.nossr50.skills.unarmed;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@@ -17,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.ToolType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
@@ -24,6 +15,13 @@ import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Item;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.block.data.BlockData;
public class UnarmedManager extends SkillManager {
public UnarmedManager(McMMOPlayer mcMMOPlayer) {
@@ -43,13 +41,13 @@ public class UnarmedManager extends SkillManager {
}
public boolean canDisarm(LivingEntity target) {
return target instanceof Player && ((Player) target).getItemInHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM);
return target instanceof Player && ((Player) target).getInventory().getItemInMainHand().getType() != Material.AIR && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DISARM);
}
public boolean canDeflect() {
Player player = getPlayer();
return ItemUtils.isUnarmed(player.getItemInHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
return ItemUtils.isUnarmed(player.getInventory().getItemInMainHand()) && Permissions.secondaryAbilityEnabled(getPlayer(), SecondaryAbility.DEFLECT);
}
public boolean canUseBlockCracker() {
@@ -61,22 +59,15 @@ public class UnarmedManager extends SkillManager {
return false;
}
MaterialData data = blockState.getData();
BlockData data = blockState.getBlockData();
switch (blockState.getType()) {
case SMOOTH_BRICK:
case STONE_BRICKS:
if (!Unarmed.blockCrackerSmoothBrick) {
return false;
}
// Yes, this is awkward, but it's the *right* way to do it.
SmoothBrick smoothBrick = (SmoothBrick) data;
if (smoothBrick.getMaterial() != Material.STONE) {
return false;
}
smoothBrick.setMaterial(Material.COBBLESTONE);
blockState.setType(Material.CRACKED_STONE_BRICKS);
return true;
default:
@@ -95,13 +86,13 @@ public class UnarmedManager extends SkillManager {
return;
}
Item item = Misc.dropItem(defender.getLocation(), defender.getItemInHand());
Item item = Misc.dropItem(defender.getLocation(), defender.getInventory().getItemInMainHand());
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
}
defender.setItemInHand(new ItemStack(Material.AIR));
defender.getInventory().setItemInMainHand(new ItemStack(Material.AIR));
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
}
}

View File

@@ -1,24 +1,22 @@
package com.gmail.nossr50.skills.woodcutting;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.util.BlockUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.skills.SkillUtils;
public final class Woodcutting {
public static int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel();
public static int treeFellerThreshold = Config.getInstance().getTreeFellerThreshold();
@@ -28,7 +26,7 @@ public final class Woodcutting {
protected enum ExperienceGainMethod {
DEFAULT,
TREE_FELLER,
};
}
private Woodcutting() {}
@@ -40,29 +38,11 @@ public final class Woodcutting {
* @return Amount of experience
*/
protected static int getExperienceFromLog(BlockState blockState, ExperienceGainMethod experienceGainMethod) {
// Mushrooms aren't trees so we could never get species data from them
switch (blockState.getType()) {
case HUGE_MUSHROOM_1:
return ExperienceConfig.getInstance().getWoodcuttingXPHugeBrownMushroom();
case HUGE_MUSHROOM_2:
return ExperienceConfig.getInstance().getWoodcuttingXPHugeRedMushroom();
default:
break;
}
if (mcMMO.getModManager().isCustomLog(blockState)) {
return mcMMO.getModManager().getBlock(blockState).getXpGain();
}
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
return ExperienceConfig.getInstance().getWoodcuttingTreeXP(species);
return ExperienceConfig.getInstance().getXp(SkillType.WOODCUTTING, blockState.getType());
}
/**
@@ -72,26 +52,11 @@ public final class Woodcutting {
*/
protected static void checkForDoubleDrop(BlockState blockState) {
if (mcMMO.getModManager().isCustomLog(blockState) && mcMMO.getModManager().getBlock(blockState).isDoubleDropEnabled()) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
else {
//TODO Remove this workaround when casting to Tree works again
TreeSpecies species = TreeSpecies.GENERIC;
if (blockState.getData() instanceof Tree) {
species = ((Tree) blockState.getData()).getSpecies();
}
if (blockState.getType() == Material.LOG_2) {
byte data = blockState.getRawData();
if ((data & 1) != 0) {
species = TreeSpecies.ACACIA;
}
if ((data & 2) != 0) {
species = TreeSpecies.DARK_OAK;
}
}
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(species)) {
Misc.dropItems(blockState.getLocation(), blockState.getBlock().getDrops());
if (Config.getInstance().getWoodcuttingDoubleDropsEnabled(blockState.getBlockData())) {
Misc.dropItems(Misc.getBlockCenter(blockState), blockState.getBlock().getDrops());
}
}
}

View File

@@ -1,17 +1,5 @@
package com.gmail.nossr50.skills.woodcutting;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.Tree;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.AbilityType;
@@ -19,14 +7,20 @@ import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.datatypes.skills.XPGainReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.SkillManager;
import com.gmail.nossr50.skills.woodcutting.Woodcutting.ExperienceGainMethod;
import com.gmail.nossr50.util.EventUtils;
import com.gmail.nossr50.util.ItemUtils;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.*;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.HashSet;
import java.util.Set;
public class WoodcuttingManager extends SkillManager {
public WoodcuttingManager(McMMOPlayer mcMMOPlayer) {
@@ -54,8 +48,8 @@ public class WoodcuttingManager extends SkillManager {
int xp = Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.DEFAULT);
switch (blockState.getType()) {
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
case BROWN_MUSHROOM_BLOCK:
case RED_MUSHROOM_BLOCK:
break;
default:
@@ -89,7 +83,7 @@ public class WoodcuttingManager extends SkillManager {
}
// If the tool can't sustain the durability loss
if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getItemInHand())) {
if (!Woodcutting.handleDurabilityLoss(treeFellerBlocks, player.getInventory().getItemInMainHand())) {
player.sendMessage(LocaleLoader.getString("Woodcutting.Skills.TreeFeller.Splinter"));
double health = player.getHealth();
@@ -123,9 +117,9 @@ public class WoodcuttingManager extends SkillManager {
Material material = blockState.getType();
if (material == Material.HUGE_MUSHROOM_1 || material == Material.HUGE_MUSHROOM_2) {
if (material == Material.BROWN_MUSHROOM_BLOCK || material == Material.RED_MUSHROOM_BLOCK) {
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItems(blockState.getLocation(), block.getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
}
else if (mcMMO.getModManager().isCustomLog(blockState)) {
if (canGetDoubleDrops()) {
@@ -135,35 +129,22 @@ public class WoodcuttingManager extends SkillManager {
CustomBlock customBlock = mcMMO.getModManager().getBlock(blockState);
xp = customBlock.getXpGain();
Misc.dropItems(blockState.getLocation(), block.getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
}
else if (mcMMO.getModManager().isCustomLeaf(blockState)) {
Misc.dropItems(blockState.getLocation(), block.getDrops());
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
}
else {
//TODO Remove this workaround when casting to Tree works again
if (blockState.getData() instanceof Tree) {
Tree tree = (Tree) blockState.getData();
tree.setDirection(BlockFace.UP);
if (BlockUtils.isLog(blockState)) {
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
}
switch (material) {
case LOG:
case LOG_2:
if (canGetDoubleDrops()) {
Woodcutting.checkForDoubleDrop(blockState);
}
xp += Woodcutting.getExperienceFromLog(blockState, ExperienceGainMethod.TREE_FELLER);
Misc.dropItems(blockState.getLocation(), block.getDrops());
break;
case LEAVES:
case LEAVES_2:
Misc.dropItems(blockState.getLocation(), block.getDrops());
break;
default:
break;
if (BlockUtils.isLeaves(blockState)) {
Misc.dropItems(Misc.getBlockCenter(blockState), block.getDrops());
}
}

View File

@@ -1,28 +1,26 @@
package com.gmail.nossr50.util;
import java.util.HashSet;
import org.bukkit.CropState;
import org.bukkit.Material;
import org.bukkit.NetherWartsState;
import org.bukkit.block.BlockState;
import org.bukkit.material.CocoaPlant;
import org.bukkit.material.CocoaPlant.CocoaPlantSize;
import org.bukkit.material.Crops;
import org.bukkit.material.NetherWarts;
import org.bukkit.material.SmoothBrick;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import java.util.HashSet;
public final class BlockUtils {
private BlockUtils() {}
/**
* Checks to see if a given block awards XP.
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block awards XP, false otherwise
*/
public static boolean shouldBeWatched(BlockState blockState) {
@@ -32,52 +30,100 @@ public final class BlockUtils {
/**
* Check if a given block should allow for the activation of abilities
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should allow ability activation, false otherwise
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should allow ability activation, false
* otherwise
*/
public static boolean canActivateAbilities(BlockState blockState) {
switch (blockState.getType()) {
case BED_BLOCK:
case BREWING_STAND:
case BOOKSHELF:
case BURNING_FURNACE:
case CAKE_BLOCK:
case CHEST:
case DISPENSER:
case ENCHANTMENT_TABLE:
case ENDER_CHEST:
case FENCE_GATE:
case FURNACE:
case IRON_DOOR_BLOCK:
case JUKEBOX:
case LEVER:
case NOTE_BLOCK:
case STONE_BUTTON:
case WOOD_BUTTON:
case TRAP_DOOR:
case WALL_SIGN:
case WOODEN_DOOR:
case WORKBENCH:
case BEACON:
case ANVIL:
case DROPPER:
case HOPPER:
case TRAPPED_CHEST:
case IRON_DOOR:
case IRON_TRAPDOOR:
case ACACIA_DOOR:
case SPRUCE_DOOR:
case BIRCH_DOOR:
case JUNGLE_DOOR:
case DARK_OAK_DOOR:
case ACACIA_FENCE:
case DARK_OAK_FENCE:
case BIRCH_FENCE:
case JUNGLE_FENCE:
case ARMOR_STAND:
case BLACK_BED:
case BLUE_BED:
case BROWN_BED:
case CYAN_BED:
case GRAY_BED:
case GREEN_BED:
case LIGHT_BLUE_BED:
case LIGHT_GRAY_BED:
case LIME_BED:
case MAGENTA_BED:
case ORANGE_BED:
case PINK_BED:
case PURPLE_BED:
case RED_BED:
case WHITE_BED:
case YELLOW_BED:
case BREWING_STAND :
case BOOKSHELF :
case CAKE:
case CHEST :
case DISPENSER :
case ENCHANTING_TABLE:
case ENDER_CHEST :
case OAK_FENCE_GATE:
case ACACIA_FENCE_GATE :
case DARK_OAK_FENCE_GATE :
case SPRUCE_FENCE_GATE :
case BIRCH_FENCE_GATE :
case JUNGLE_FENCE_GATE :
case FURNACE :
case JUKEBOX :
case LEVER :
case NOTE_BLOCK :
case STONE_BUTTON :
case OAK_BUTTON:
case BIRCH_BUTTON:
case ACACIA_BUTTON:
case DARK_OAK_BUTTON:
case JUNGLE_BUTTON:
case SPRUCE_BUTTON:
case ACACIA_TRAPDOOR:
case BIRCH_TRAPDOOR:
case DARK_OAK_TRAPDOOR:
case JUNGLE_TRAPDOOR:
case OAK_TRAPDOOR:
case SPRUCE_TRAPDOOR:
case WALL_SIGN :
case CRAFTING_TABLE:
case BEACON :
case ANVIL :
case DROPPER :
case HOPPER :
case TRAPPED_CHEST :
case IRON_DOOR :
case IRON_TRAPDOOR :
case OAK_DOOR:
case ACACIA_DOOR :
case SPRUCE_DOOR :
case BIRCH_DOOR :
case JUNGLE_DOOR :
case DARK_OAK_DOOR :
case OAK_FENCE:
case ACACIA_FENCE :
case DARK_OAK_FENCE :
case BIRCH_FENCE :
case JUNGLE_FENCE :
case SPRUCE_FENCE :
case ARMOR_STAND :
case BLACK_SHULKER_BOX :
case BLUE_SHULKER_BOX :
case BROWN_SHULKER_BOX :
case CYAN_SHULKER_BOX :
case GRAY_SHULKER_BOX :
case GREEN_SHULKER_BOX :
case LIGHT_BLUE_SHULKER_BOX :
case LIME_SHULKER_BOX :
case MAGENTA_SHULKER_BOX :
case ORANGE_SHULKER_BOX :
case PINK_SHULKER_BOX :
case PURPLE_SHULKER_BOX :
case RED_SHULKER_BOX :
case LIGHT_GRAY_SHULKER_BOX:
case WHITE_SHULKER_BOX :
case YELLOW_SHULKER_BOX :
return false;
default:
default :
return !isMcMMOAnvil(blockState) && !mcMMO.getModManager().isCustomAbilityBlock(blockState);
}
}
@@ -85,32 +131,35 @@ public final class BlockUtils {
/**
* Check if a given block is an ore
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block is an ore, false otherwise
*/
public static boolean isOre(BlockState blockState) {
return MaterialUtils.isOre(blockState.getData());
return MaterialUtils.isOre(blockState.getType());
}
/**
* Determine if a given block can be made mossy
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block can be made mossy, false otherwise
*/
public static boolean canMakeMossy(BlockState blockState) {
switch (blockState.getType()) {
case COBBLESTONE:
case DIRT:
case COBBLESTONE :
case DIRT :
case GRASS_PATH :
return true;
case SMOOTH_BRICK:
return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE;
case STONE_BRICKS:
return true;
case COBBLE_WALL:
return blockState.getRawData() == (byte) 0x0;
case COBBLESTONE_WALL:
return true;
default:
default :
return false;
}
}
@@ -118,126 +167,78 @@ public final class BlockUtils {
/**
* Determine if a given block should be affected by Green Terra
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should affected by Green Terra, false otherwise
*/
public static boolean affectedByGreenTerra(BlockState blockState) {
switch (blockState.getType()) {
case BROWN_MUSHROOM:
case CACTUS:
case DOUBLE_PLANT:
case MELON_BLOCK:
case LONG_GRASS:
case PUMPKIN:
case RED_MUSHROOM:
case RED_ROSE:
case SUGAR_CANE_BLOCK:
case VINE:
case WATER_LILY:
case YELLOW_FLOWER:
return true;
case CARROT:
case POTATO:
return blockState.getRawData() == CropState.RIPE.getData();
case CROPS:
return ((Crops) blockState.getData()).getState() == CropState.RIPE;
case NETHER_WARTS:
return ((NetherWarts) blockState.getData()).getState() == NetherWartsState.RIPE;
case COCOA:
return ((CocoaPlant) blockState.getData()).getSize() == CocoaPlantSize.LARGE;
default:
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.HERBALISM, blockState.getBlockData())) {
return true;
}
return mcMMO.getModManager().isCustomHerbalismBlock(blockState);
}
/**
* Determine if a given block should be affected by Super Breaker
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Super Breaker, false otherwise
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should affected by Super Breaker, false
* otherwise
*/
public static Boolean affectedBySuperBreaker(BlockState blockState) {
switch (blockState.getType()) {
case ENDER_STONE:
case GLOWSTONE:
case HARD_CLAY:
case MOSSY_COBBLESTONE:
case NETHERRACK:
case OBSIDIAN:
case PACKED_ICE:
case SANDSTONE:
case STAINED_CLAY:
case STONE:
case PRISMARINE:
case RED_SANDSTONE:
return true;
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.MINING, blockState.getBlockData()))
return true;
default:
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
}
return isOre(blockState) || mcMMO.getModManager().isCustomMiningBlock(blockState);
}
/**
* Determine if a given block should be affected by Giga Drill Breaker
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Giga Drill Breaker, false otherwise
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should affected by Giga Drill Breaker, false
* otherwise
*/
public static boolean affectedByGigaDrillBreaker(BlockState blockState) {
switch (blockState.getType()) {
case CLAY:
case DIRT:
case GRASS:
case GRAVEL:
case MYCEL:
case SAND:
case SNOW:
case SNOW_BLOCK:
case SOUL_SAND:
return true;
default:
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
}
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.EXCAVATION, blockState.getBlockData()))
return true;
return mcMMO.getModManager().isCustomExcavationBlock(blockState);
}
/**
* Check if a given block is a log
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block is a log, false otherwise
*/
public static boolean isLog(BlockState blockState) {
switch (blockState.getType()) {
case LOG:
case LOG_2:
case HUGE_MUSHROOM_1:
case HUGE_MUSHROOM_2:
return true;
default:
return mcMMO.getModManager().isCustomLog(blockState);
}
if (ExperienceConfig.getInstance().isSkillBlock(SkillType.WOODCUTTING, blockState.getBlockData()))
return true;
return mcMMO.getModManager().isCustomLog(blockState);
}
/**
* Check if a given block is a leaf
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block is a leaf, false otherwise
*/
public static boolean isLeaves(BlockState blockState) {
switch (blockState.getType()) {
case LEAVES:
case LEAVES_2:
case OAK_LEAVES:
case ACACIA_LEAVES:
case BIRCH_LEAVES:
case DARK_OAK_LEAVES:
case JUNGLE_LEAVES:
case SPRUCE_LEAVES:
return true;
default:
default :
return mcMMO.getModManager().isCustomLeaf(blockState);
}
}
@@ -245,16 +246,17 @@ public final class BlockUtils {
/**
* Determine if a given block should be affected by Flux Mining
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should affected by Flux Mining, false otherwise
*/
public static boolean affectedByFluxMining(BlockState blockState) {
switch (blockState.getType()) {
case IRON_ORE:
case GOLD_ORE:
case IRON_ORE :
case GOLD_ORE :
return true;
default:
default :
return false;
}
}
@@ -262,17 +264,20 @@ public final class BlockUtils {
/**
* Determine if a given block can activate Herbalism abilities
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block can be activate Herbalism abilities, false otherwise
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block can be activate Herbalism abilities, false
* otherwise
*/
public static boolean canActivateHerbalism(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
case GRASS:
case SOIL:
case DIRT :
case GRASS :
case GRASS_PATH :
case FARMLAND:
return false;
default:
default :
return true;
}
}
@@ -280,15 +285,17 @@ public final class BlockUtils {
/**
* Determine if a given block should be affected by Block Cracker
*
* @param blockState The {@link BlockState} of the block to check
* @return true if the block should affected by Block Cracker, false otherwise
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block should affected by Block Cracker, false
* otherwise
*/
public static boolean affectedByBlockCracker(BlockState blockState) {
switch (blockState.getType()) {
case SMOOTH_BRICK:
return ((SmoothBrick) blockState.getData()).getMaterial() == Material.STONE;
case STONE_BRICKS:
return true;
default:
default :
return false;
}
}
@@ -296,16 +303,18 @@ public final class BlockUtils {
/**
* Determine if a given block can be made into Mycelium
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block can be made into Mycelium, false otherwise
*/
public static boolean canMakeShroomy(BlockState blockState) {
switch (blockState.getType()) {
case DIRT:
case GRASS:
case DIRT :
case GRASS :
case GRASS_PATH :
return true;
default:
default :
return false;
}
}
@@ -313,7 +322,8 @@ public final class BlockUtils {
/**
* Determine if a given block is an mcMMO anvil
*
* @param blockState The {@link BlockState} of the block to check
* @param blockState
* The {@link BlockState} of the block to check
* @return true if the block is an mcMMO anvil, false otherwise
*/
public static boolean isMcMMOAnvil(BlockState blockState) {
@@ -325,7 +335,7 @@ public final class BlockUtils {
public static boolean isPistonPiece(BlockState blockState) {
Material type = blockState.getType();
return type == Material.PISTON_MOVING_PIECE || type == Material.AIR;
return type == Material.MOVING_PISTON || type == Material.AIR;
}
/**
@@ -333,15 +343,27 @@ public final class BlockUtils {
*
* @return HashSet with the IDs of every transparent block
*/
public static HashSet<Byte> getTransparentBlocks() {
HashSet<Byte> transparentBlocks = new HashSet<Byte>();
public static HashSet<Material> getTransparentBlocks() {
HashSet<Material> transparentBlocks = new HashSet<Material>();
for (Material material : Material.values()) {
if (material.isTransparent()) {
transparentBlocks.add((byte) material.getId());
transparentBlocks.add(material);
}
}
return transparentBlocks;
}
public static boolean isFullyGrown(BlockState blockState) {
BlockData data = blockState.getBlockData();
if (data.getMaterial() == Material.CACTUS || data.getMaterial() == Material.SUGAR_CANE)
return true;
if (data instanceof Ageable)
{
Ageable ageable = (Ageable) data;
return ageable.getAge() == ageable.getMaximumAge();
}
return true;
}
}

View File

@@ -1,27 +1,22 @@
package com.gmail.nossr50.util;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.Vector;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.metrics.MetricsManager;
import com.gmail.nossr50.runnables.items.ChimaeraWingWarmup;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.SkillUtils;
import java.util.ArrayList;
import java.util.List;
public final class ChimaeraWing {
private static McMMOPlayer mcMMOPlayer;
@@ -39,7 +34,7 @@ public final class ChimaeraWing {
return;
}
ItemStack inHand = player.getItemInHand();
ItemStack inHand = player.getInventory().getItemInMainHand();
if (!ItemUtils.isChimaeraWing(inHand)) {
return;
@@ -91,7 +86,7 @@ public final class ChimaeraWing {
if (Config.getInstance().getChimaeraPreventUseUnderground()) {
if (location.getY() < player.getWorld().getHighestBlockYAt(location)) {
player.setItemInHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(amount - Config.getInstance().getChimaeraUseCost())));
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail"));
player.updateInventory();
player.setVelocity(new Vector(0, 0.5D, 0));
@@ -130,17 +125,13 @@ public final class ChimaeraWing {
}
}
player.setItemInHand(new ItemStack(getChimaeraWing(player.getItemInHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.getInventory().setItemInMainHand(new ItemStack(getChimaeraWing(player.getInventory().getItemInMainHand().getAmount() - Config.getInstance().getChimaeraUseCost())));
player.updateInventory();
mcMMOPlayer.actualizeChimeraWingLastUse();
mcMMOPlayer.setTeleportCommenceLocation(null);
if (Config.getInstance().getStatsTrackingEnabled()) {
MetricsManager.chimeraWingUsed();
}
if (Config.getInstance().getChimaeraSoundEnabled()) {
player.playSound(location, Sound.BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
player.playSound(location, Sound.ENTITY_BAT_TAKEOFF, Misc.BAT_VOLUME, Misc.BAT_PITCH);
}
player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Pass"));
@@ -165,7 +156,7 @@ public final class ChimaeraWing {
Material ingredient = Config.getInstance().getChimaeraItem();
int amount = Config.getInstance().getChimaeraRecipeCost();
ShapelessRecipe chimeraWing = new ShapelessRecipe(getChimaeraWing(1));
ShapelessRecipe chimeraWing = new ShapelessRecipe(new NamespacedKey(mcMMO.p, "Chimera"), getChimaeraWing(1));
chimeraWing.addIngredient(amount, ingredient);
return chimeraWing;
}

View File

@@ -31,6 +31,9 @@ public class EnchantmentUtils {
enchants.put("FLAME", Enchantment.ARROW_FIRE);
enchants.put("KNOCKBACK", Enchantment.KNOCKBACK);
enchants.put("THORNS", Enchantment.THORNS);
enchants.put("MENDING", Enchantment.MENDING);
enchants.put("DEPTH_STRIDER", Enchantment.DEPTH_STRIDER);
enchants.put("FROST_WALKER", Enchantment.FROST_WALKER);
}
/**
@@ -45,6 +48,6 @@ public class EnchantmentUtils {
return enchants.get(enchantmentName);
}
return null;
return Enchantment.getByName(enchantmentName);
}
}

View File

@@ -1,17 +1,5 @@
package com.gmail.nossr50.util;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Fish;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.player.PlayerProfile;
@@ -40,8 +28,20 @@ import com.gmail.nossr50.events.skills.fishing.McMMOPlayerMagicHunterEvent;
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
import com.gmail.nossr50.events.skills.secondaryabilities.SecondaryAbilityEvent;
import com.gmail.nossr50.events.skills.unarmed.McMMOPlayerDisarmEvent;
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.FishHook;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.PluginManager;
import java.util.HashMap;
import java.util.Map;
public class EventUtils {
public static McMMOPlayerAbilityActivateEvent callPlayerAbilityActivateEvent(Player player, SkillType skill) {
@@ -97,7 +97,7 @@ public class EventUtils {
callFakeArmSwingEvent(player);
}
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getItemInHand(), true);
FakeBlockDamageEvent damageEvent = new FakeBlockDamageEvent(player, block, player.getInventory().getItemInMainHand(), true);
pluginManager.callEvent(damageEvent);
FakeBlockBreakEvent breakEvent = new FakeBlockBreakEvent(block, player);
@@ -252,7 +252,7 @@ public class EventUtils {
return event;
}
public static FakePlayerFishEvent callFakeFishEvent(Player player, Fish hook) {
public static FakePlayerFishEvent callFakeFishEvent(Player player, FishHook hook) {
FakePlayerFishEvent event = new FakePlayerFishEvent(player, null, hook, PlayerFishEvent.State.FISHING);
mcMMO.p.getServer().getPluginManager().callEvent(event);
@@ -279,4 +279,11 @@ public class EventUtils {
return event;
}
public static McMMOPlayerSalvageCheckEvent callSalvageCheckEvent(Player player, ItemStack salvageMaterial, ItemStack salvageResults, ItemStack enchantedBook) {
McMMOPlayerSalvageCheckEvent event = new McMMOPlayerSalvageCheckEvent(player, salvageMaterial, salvageResults, enchantedBook);
mcMMO.p.getServer().getPluginManager().callEvent(event);
return event;
}
}

View File

@@ -1,28 +1,13 @@
package com.gmail.nossr50.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.EnumSet;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect;
import com.gmail.nossr50.commands.skills.AprilCommand;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.collect.ImmutableList;
import org.bukkit.*;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.Sound;
import org.bukkit.Statistic;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.EntityType;
@@ -31,13 +16,9 @@ import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerStatisticIncrementEvent;
import org.bukkit.inventory.meta.FireworkMeta;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.skills.AprilCommand;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.google.common.collect.ImmutableList;
import java.io.*;
import java.util.*;
import java.util.regex.Pattern;
public final class HolidayManager {
private ArrayList<String> hasCelebrated;
@@ -95,7 +76,7 @@ public final class HolidayManager {
return FakeSkillType.CLIMBING;
case FLY_ONE_CM:
return FakeSkillType.FLYING;
case DIVE_ONE_CM:
case WALK_UNDER_WATER_ONE_CM:
return FakeSkillType.DIVING;
case PIG_ONE_CM:
return FakeSkillType.PIGGY;
@@ -107,7 +88,7 @@ public final class HolidayManager {
public final Set<Statistic> movementStatistics = EnumSet.of(
Statistic.WALK_ONE_CM, Statistic.SWIM_ONE_CM, Statistic.FALL_ONE_CM,
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.DIVE_ONE_CM,
Statistic.CLIMB_ONE_CM, Statistic.FLY_ONE_CM, Statistic.WALK_UNDER_WATER_ONE_CM,
Statistic.PIG_ONE_CM);
static {
@@ -376,7 +357,7 @@ public final class HolidayManager {
public void levelUpApril(Player player, FakeSkillType fakeSkillType) {
int levelTotal = Misc.getRandom().nextInt(1 + UserManager.getPlayer(player).getSkillLevel(SkillType.MINING)) + 1;
player.playSound(player.getLocation(), Sound.LEVEL_UP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, Misc.LEVELUP_VOLUME, Misc.LEVELUP_PITCH);
player.sendMessage(ChatColor.YELLOW + StringUtils.getCapitalized(fakeSkillType.toString()) + " skill increased by 1. Total (" + levelTotal + ")");
ParticleEffectUtils.fireworkParticleShower(player, ALL_COLORS.get(Misc.getRandom().nextInt(ALL_COLORS.size())));
}

View File

@@ -1,20 +1,15 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import org.bukkit.ChatColor;
import org.bukkit.CoalType;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.FurnaceRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Coal;
import org.bukkit.material.Dye;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.locale.LocaleLoader;
public final class ItemUtils {
private ItemUtils() {}
@@ -48,10 +43,10 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_SWORD:
case GOLD_SWORD:
case GOLDEN_SWORD:
case IRON_SWORD:
case STONE_SWORD:
case WOOD_SWORD:
case WOODEN_SWORD:
return true;
default:
@@ -70,10 +65,10 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_HOE:
case GOLD_HOE:
case GOLDEN_HOE:
case IRON_HOE:
case STONE_HOE:
case WOOD_HOE:
case WOODEN_HOE:
return true;
default:
@@ -91,11 +86,11 @@ public final class ItemUtils {
Material type = item.getType();
switch (type) {
case DIAMOND_SPADE:
case GOLD_SPADE:
case IRON_SPADE:
case STONE_SPADE:
case WOOD_SPADE:
case DIAMOND_SHOVEL:
case GOLDEN_SHOVEL:
case IRON_SHOVEL:
case STONE_SHOVEL:
case WOODEN_SHOVEL:
return true;
default:
@@ -114,10 +109,10 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_AXE:
case GOLD_AXE:
case GOLDEN_AXE:
case IRON_AXE:
case STONE_AXE:
case WOOD_AXE:
case WOODEN_AXE:
return true;
default:
@@ -136,10 +131,10 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_PICKAXE:
case GOLD_PICKAXE:
case GOLDEN_PICKAXE:
case IRON_PICKAXE:
case STONE_PICKAXE:
case WOOD_PICKAXE:
case WOODEN_PICKAXE:
return true;
default:
@@ -172,7 +167,7 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_HELMET:
case GOLD_HELMET:
case GOLDEN_HELMET:
case IRON_HELMET:
case CHAINMAIL_HELMET:
case LEATHER_HELMET:
@@ -194,7 +189,7 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_CHESTPLATE:
case GOLD_CHESTPLATE:
case GOLDEN_CHESTPLATE:
case IRON_CHESTPLATE:
case CHAINMAIL_CHESTPLATE:
case LEATHER_CHESTPLATE:
@@ -216,7 +211,7 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_LEGGINGS:
case GOLD_LEGGINGS:
case GOLDEN_LEGGINGS:
case IRON_LEGGINGS:
case CHAINMAIL_LEGGINGS:
case LEATHER_LEGGINGS:
@@ -238,7 +233,7 @@ public final class ItemUtils {
switch (type) {
case DIAMOND_BOOTS:
case GOLD_BOOTS:
case GOLDEN_BOOTS:
case IRON_BOOTS:
case CHAINMAIL_BOOTS:
case LEATHER_BOOTS:
@@ -296,10 +291,10 @@ public final class ItemUtils {
*/
public static boolean isGoldArmor(ItemStack item) {
switch (item.getType()) {
case GOLD_BOOTS:
case GOLD_CHESTPLATE:
case GOLD_HELMET:
case GOLD_LEGGINGS:
case GOLDEN_BOOTS:
case GOLDEN_CHESTPLATE:
case GOLDEN_HELMET:
case GOLDEN_LEGGINGS:
return true;
default:
@@ -385,7 +380,7 @@ public final class ItemUtils {
case STONE_AXE:
case STONE_HOE:
case STONE_PICKAXE:
case STONE_SPADE:
case STONE_SHOVEL:
case STONE_SWORD:
return true;
@@ -402,11 +397,11 @@ public final class ItemUtils {
*/
public static boolean isWoodTool(ItemStack item) {
switch (item.getType()) {
case WOOD_AXE:
case WOOD_HOE:
case WOOD_PICKAXE:
case WOOD_SPADE:
case WOOD_SWORD:
case WOODEN_AXE:
case WOODEN_HOE:
case WOODEN_PICKAXE:
case WOODEN_SHOVEL:
case WOODEN_SWORD:
return true;
default:
@@ -423,7 +418,7 @@ public final class ItemUtils {
public static boolean isStringTool(ItemStack item) {
switch (item.getType()) {
case BOW:
case CARROT_STICK:
case CARROT_ON_A_STICK:
case FISHING_ROD:
return true;
@@ -440,11 +435,11 @@ public final class ItemUtils {
*/
public static boolean isGoldTool(ItemStack item) {
switch (item.getType()) {
case GOLD_AXE:
case GOLD_HOE:
case GOLD_PICKAXE:
case GOLD_SPADE:
case GOLD_SWORD:
case GOLDEN_AXE:
case GOLDEN_HOE:
case GOLDEN_PICKAXE:
case GOLDEN_SHOVEL:
case GOLDEN_SWORD:
return true;
default:
@@ -465,7 +460,7 @@ public final class ItemUtils {
case IRON_AXE:
case IRON_HOE:
case IRON_PICKAXE:
case IRON_SPADE:
case IRON_SHOVEL:
case IRON_SWORD:
case SHEARS:
return true;
@@ -486,7 +481,7 @@ public final class ItemUtils {
case DIAMOND_AXE:
case DIAMOND_HOE:
case DIAMOND_PICKAXE:
case DIAMOND_SPADE:
case DIAMOND_SHOVEL:
case DIAMOND_SWORD:
return true;
@@ -503,10 +498,12 @@ public final class ItemUtils {
*/
public static boolean isEnchantable(ItemStack item) {
switch (item.getType()) {
case ENCHANTED_BOOK:
case SHEARS:
case FISHING_ROD:
case CARROT_STICK:
case CARROT_ON_A_STICK:
case FLINT_AND_STEEL:
case TRIDENT:
return true;
default:
@@ -515,7 +512,7 @@ public final class ItemUtils {
}
public static boolean isSmeltable(ItemStack item) {
return item != null && MaterialUtils.isOre(item.getData());
return item != null && item.getType().isBlock() && MaterialUtils.isOre(item.getType());
}
public static boolean isSmelted(ItemStack item) {
@@ -524,8 +521,8 @@ public final class ItemUtils {
}
for (Recipe recipe : mcMMO.p.getServer().getRecipesFor(item)) {
if (recipe instanceof FurnaceRecipe) {
return MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getData());
if (recipe instanceof FurnaceRecipe && ((FurnaceRecipe) recipe).getInput().getType().isBlock() && MaterialUtils.isOre(((FurnaceRecipe) recipe).getInput().getType())) {
return true;
}
}
@@ -567,12 +564,10 @@ public final class ItemUtils {
case REDSTONE:
case GLOWSTONE_DUST: // Should we also have Glowstone here?
case QUARTZ:
case QUARTZ_ORE:
case NETHER_QUARTZ_ORE:
case LAPIS_LAZULI:
return true;
case INK_SACK:
return ((Dye) item.getData()).getColor() == DyeColor.BLUE;
default:
return false;
}
@@ -587,29 +582,30 @@ public final class ItemUtils {
public static boolean isHerbalismDrop(ItemStack item) {
switch (item.getType()) {
case WHEAT:
case SEEDS:
case CARROT_ITEM:
case POTATO_ITEM:
case NETHER_WARTS:
case WHEAT_SEEDS:
case CARROT:
case CHORUS_FRUIT:
case CHORUS_FLOWER:
case POTATO:
case BEETROOT:
case BEETROOT_SEEDS:
case NETHER_WART:
case BROWN_MUSHROOM:
case RED_MUSHROOM:
case RED_ROSE:
case YELLOW_FLOWER:
case ROSE_RED:
case DANDELION_YELLOW:
case CACTUS:
case SUGAR_CANE:
case MELON:
case MELON_SEEDS:
case PUMPKIN:
case PUMPKIN_SEEDS:
case WATER_LILY:
case LILY_PAD:
case VINE:
case LONG_GRASS:
case DOUBLE_PLANT:
case TALL_GRASS:
case COCOA_BEANS:
return true;
case INK_SACK:
return ((Dye) item.getData()).getColor() == DyeColor.BROWN;
default:
return false;
}
@@ -625,19 +621,34 @@ public final class ItemUtils {
switch (item.getType()) {
case STRING:
case FEATHER:
case RAW_CHICKEN:
case CHICKEN:
case COOKED_CHICKEN:
case LEATHER:
case RAW_BEEF:
case BEEF:
case COOKED_BEEF:
case PORK:
case GRILLED_PORK:
case WOOL:
case PORKCHOP:
case COOKED_PORKCHOP:
case WHITE_WOOL:
case BLACK_WOOL:
case BLUE_WOOL:
case BROWN_WOOL:
case CYAN_WOOL:
case GRAY_WOOL:
case GREEN_WOOL:
case LIGHT_BLUE_WOOL:
case LIGHT_GRAY_WOOL:
case LIME_WOOL:
case MAGENTA_WOOL:
case ORANGE_WOOL:
case PINK_WOOL:
case PURPLE_WOOL:
case RED_WOOL:
case YELLOW_WOOL:
case IRON_INGOT:
case SNOW_BALL:
case SNOWBALL:
case BLAZE_ROD:
case SPIDER_EYE:
case SULPHUR:
case GUNPOWDER:
case ENDER_PEARL:
case GHAST_TEAR:
case MAGMA_CREAM:
@@ -648,14 +659,10 @@ public final class ItemUtils {
case ROTTEN_FLESH:
case GOLD_NUGGET:
case EGG:
case ROSE_RED:
case COAL:
return true;
case COAL: // Not sure we should include this, as it will also trigger when mining
return (((Coal) item.getData()).getType() == CoalType.COAL);
case RED_ROSE: // Not sure we should include this, as it will also trigger from herbalism
return (item.getData().getData() == 0x0);
default:
return false;
}
@@ -669,11 +676,30 @@ public final class ItemUtils {
*/
public static boolean isWoodcuttingDrop(ItemStack item) {
switch (item.getType()) {
case LOG:
case LOG_2:
case LEAVES:
case LEAVES_2:
case SAPLING:
case ACACIA_LOG:
case BIRCH_LOG:
case DARK_OAK_LOG:
case JUNGLE_LOG:
case OAK_LOG:
case SPRUCE_LOG:
case STRIPPED_ACACIA_LOG:
case STRIPPED_BIRCH_LOG:
case STRIPPED_DARK_OAK_LOG:
case STRIPPED_JUNGLE_LOG:
case STRIPPED_OAK_LOG:
case STRIPPED_SPRUCE_LOG:
case ACACIA_SAPLING:
case SPRUCE_SAPLING:
case BIRCH_SAPLING:
case DARK_OAK_SAPLING:
case JUNGLE_SAPLING:
case OAK_SAPLING:
case ACACIA_LEAVES:
case BIRCH_LEAVES:
case DARK_OAK_LEAVES:
case JUNGLE_LEAVES:
case OAK_LEAVES:
case SPRUCE_LEAVES:
case APPLE:
return true;

View File

@@ -1,21 +1,19 @@
package com.gmail.nossr50.util;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import org.bukkit.Material;
public final class MaterialUtils {
private MaterialUtils() {}
protected static boolean isOre(MaterialData data) {
switch (data.getItemType()) {
protected static boolean isOre(Material data) {
switch (data) {
case COAL_ORE:
case DIAMOND_ORE:
case GLOWING_REDSTONE_ORE:
case NETHER_QUARTZ_ORE:
case GOLD_ORE:
case IRON_ORE:
case LAPIS_ORE:
case QUARTZ_ORE:
case REDSTONE_ORE:
case EMERALD_ORE:
return true;

View File

@@ -6,6 +6,7 @@ import java.util.Set;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item;
import org.bukkit.entity.NPC;
@@ -13,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.events.items.McMMOItemSpawnEvent;
import com.gmail.nossr50.runnables.player.PlayerProfileLoadingTask;
import com.gmail.nossr50.util.player.UserManager;
@@ -30,14 +32,14 @@ public final class Misc {
// Sound Pitches & Volumes from CB
public static final float ANVIL_USE_PITCH = 0.3F; // Not in CB directly, I went off the place sound values
public static final float ANVIL_USE_VOLUME = 1.0F; // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F;
public static final float POP_VOLUME = 0.2F;
public static final float BAT_VOLUME = 1.0F;
public static final float ANVIL_USE_VOLUME = 1.0F * Config.getInstance().getMasterVolume(); // Not in CB directly, I went off the place sound values
public static final float FIZZ_VOLUME = 0.5F * Config.getInstance().getMasterVolume();
public static final float POP_VOLUME = 0.2F * Config.getInstance().getMasterVolume();
public static final float BAT_VOLUME = 1.0F * Config.getInstance().getMasterVolume();
public static final float BAT_PITCH = 0.6F;
public static final float GHAST_VOLUME = 1.0F;
public static final float GHAST_VOLUME = 1.0F * Config.getInstance().getMasterVolume();
public static final float LEVELUP_PITCH = 0.5F; // Reduced to differentiate between vanilla level-up
public static final float LEVELUP_VOLUME = 0.75F; // Use max volume always
public static final float LEVELUP_VOLUME = 0.75F * Config.getInstance().getMasterVolume(); // Use max volume always
public static final Set<String> modNames = ImmutableSet.of("LOTR", "BUILDCRAFT", "ENDERIO", "ENHANCEDBIOMES", "IC2", "METALLURGY", "FORESTRY", "GALACTICRAFT", "RAILCRAFT", "TWILIGHTFOREST", "THAUMCRAFT", "GRAVESTONEMOD", "GROWTHCRAFT", "ARCTICMOBS", "DEMONMOBS", "INFERNOMOBS", "SWAMPMOBS", "MARICULTURE", "MINESTRAPPOLATION");
@@ -71,6 +73,16 @@ public final class Misc {
return (first.getWorld() == second.getWorld()) && (first.distanceSquared(second) < (maxDistance * maxDistance) || maxDistance == 0);
}
/**
* Get the center of the given block.
*
* @param blockState The {@link BlockState} of the block
* @return A {@link Location} lying at the center of the block
*/
public static Location getBlockCenter(BlockState blockState) {
return blockState.getLocation().add(0.5, 0.5, 0.5);
}
public static void dropItems(Location location, Collection<ItemStack> drops) {
for (ItemStack drop : drops) {
dropItem(location, drop);
@@ -110,7 +122,7 @@ public final class Misc {
return null;
}
return location.getWorld().dropItemNaturally(location, itemStack);
return location.getWorld().dropItem(location, itemStack);
}
public static void profileCleanup(String playerName) {

View File

@@ -16,7 +16,7 @@ import com.gmail.nossr50.runnables.MobHealthDisplayUpdaterTask;
import com.gmail.nossr50.util.player.UserManager;
public final class MobHealthbarUtils {
private MobHealthbarUtils() {};
private MobHealthbarUtils() {}
/**
* Fix issues with death messages caused by the mob healthbars.
@@ -40,7 +40,7 @@ public final class MobHealthbarUtils {
* @param damage damage done by the attack triggering this
*/
public static void handleMobHealthbars(Player player, LivingEntity target, double damage) {
if (mcMMO.isHealthBarPluginEnabled() || !Permissions.mobHealthDisplay(player)) {
if (mcMMO.isHealthBarPluginEnabled() || !Permissions.mobHealthDisplay(player) || !Config.getInstance().getMobHealthbarEnabled()) {
return;
}

View File

@@ -1,18 +1,5 @@
package com.gmail.nossr50.util;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.mods.CustomArmorConfig;
import com.gmail.nossr50.config.mods.CustomBlockConfig;
@@ -21,7 +8,18 @@ import com.gmail.nossr50.config.mods.CustomToolConfig;
import com.gmail.nossr50.datatypes.mods.CustomBlock;
import com.gmail.nossr50.datatypes.mods.CustomEntity;
import com.gmail.nossr50.datatypes.mods.CustomTool;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.repairables.Repairable;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class ModManager {
private List<Repairable> repairables = new ArrayList<Repairable>();
@@ -33,14 +31,14 @@ public class ModManager {
private List<Material> customLeggings = new ArrayList<Material>();
// Block Mods
private List<MaterialData> customExcavationBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customHerbalismBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customMiningBlocks = new ArrayList<MaterialData>();
private List<MaterialData> customOres = new ArrayList<MaterialData>();
private List<MaterialData> customLogs = new ArrayList<MaterialData>();
private List<MaterialData> customLeaves = new ArrayList<MaterialData>();
private List<MaterialData> customAbilityBlocks = new ArrayList<MaterialData>();
private HashMap<MaterialData, CustomBlock> customBlockMap = new HashMap<MaterialData, CustomBlock>();
private List<Material> customExcavationBlocks = new ArrayList<Material>();
private List<Material> customHerbalismBlocks = new ArrayList<Material>();
private List<Material> customMiningBlocks = new ArrayList<Material>();
private List<Material> customOres = new ArrayList<Material>();
private List<Material> customLogs = new ArrayList<Material>();
private List<Material> customLeaves = new ArrayList<Material>();
private List<Material> customAbilityBlocks = new ArrayList<Material>();
private HashMap<Material, CustomBlock> customBlockMap = new HashMap<>();
// Entity Mods
private HashMap<String, CustomEntity> customEntityClassMap = new HashMap<String, CustomEntity>();
@@ -130,39 +128,39 @@ public class ModManager {
return Config.getInstance().getToolModsEnabled() && customSwords.contains(material);
}
public boolean isCustomOre(MaterialData data) {
public boolean isCustomOre(Material data) {
return Config.getInstance().getBlockModsEnabled() && customOres.contains(data);
}
public boolean isCustomLog(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customLogs.contains(state.getType());
}
public boolean isCustomLeaf(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customLeaves.contains(state.getType());
}
public boolean isCustomAbilityBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customAbilityBlocks.contains(state.getType());
}
public boolean isCustomExcavationBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customExcavationBlocks.contains(state.getType());
}
public boolean isCustomHerbalismBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customHerbalismBlocks.contains(state.getType());
}
public boolean isCustomMiningBlock(BlockState state) {
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getData());
return Config.getInstance().getBlockModsEnabled() && customMiningBlocks.contains(state.getType());
}
public CustomBlock getBlock(BlockState state) {
return customBlockMap.get(state.getData());
return customBlockMap.get(state.getType());
}
public CustomBlock getBlock(MaterialData data) {
public CustomBlock getBlock(Material data) {
return customBlockMap.get(data);
}

View File

@@ -1,18 +1,21 @@
package com.gmail.nossr50.util;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.entity.EntityType;
import com.gmail.nossr50.datatypes.party.PartyFeature;
import com.gmail.nossr50.datatypes.skills.AbilityType;
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
import org.bukkit.Material;
import org.bukkit.TreeSpecies;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.EntityType;
public class StringUtils {
/**
* Gets a capitalized version of the target string.
*
* @param target String to capitalize
* @param target
* String to capitalize
* @return the capitalized string
*/
public static String getCapitalized(String target) {
@@ -34,20 +37,61 @@ public class StringUtils {
public static String getPrettyTreeSpeciesString(TreeSpecies species) {
return createPrettyEnumString(species.toString());
}
public static String getWildcardConfigBlockDataString(BlockData data) {
return getWildcardConfigMaterialString(data.getMaterial());
}
public static String getWildcardConfigMaterialString(Material data) {
return StringUtils.getPrettyItemString(data).replace(" ", "_") + "|*";
}
public static String getFriendlyConfigBlockDataString(BlockData data) {
switch(data.getMaterial()){
case CHORUS_FLOWER:
case COCOA:
case WHEAT:
case BEETROOTS:
case CARROTS:
case POTATOES:
case NETHER_WART: {
if (data instanceof Ageable) {
Ageable ageData = (Ageable) data;
if (ageData.getAge() == ageData.getMaximumAge()) {
return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ripe";
}
}
return getPrettyItemString(data.getMaterial()).replace(" ", "_") + "_Ungrown";
}
}
return getPrettyItemString(data.getMaterial()).replace(" ", "_");
}
public static String getFriendlyConfigMaterialString(Material data) {
return getPrettyItemString(data).replace(" ", "_");
}
public static String getExplicitConfigBlockDataString(BlockData data) {
return getExplicitConfigMaterialString(data.getMaterial());
}
public static String getExplicitConfigMaterialString(Material data) {
return StringUtils.getPrettyItemString(data).replace(" ", "_");
}
public static String getPrettySecondaryAbilityString(SecondaryAbility secondaryAbility) {
switch (secondaryAbility) {
case HERBALISM_DOUBLE_DROPS:
case MINING_DOUBLE_DROPS:
case WOODCUTTING_DOUBLE_DROPS:
case HERBALISM_DOUBLE_DROPS :
case MINING_DOUBLE_DROPS :
case WOODCUTTING_DOUBLE_DROPS :
return "Double Drops";
case FISHING_TREASURE_HUNTER:
case EXCAVATION_TREASURE_HUNTER:
case FISHING_TREASURE_HUNTER :
case EXCAVATION_TREASURE_HUNTER :
return "Treasure Hunter";
case GREEN_THUMB_BLOCK:
case GREEN_THUMB_PLANT:
case GREEN_THUMB_BLOCK :
case GREEN_THUMB_PLANT :
return "Green Thumb";
default:
default :
return createPrettyEnumString(secondaryAbility.toString());
}
}
@@ -77,15 +121,15 @@ public class StringUtils {
/**
* Determine if a string represents an Integer
*
* @param string String to check
* @param string
* String to check
* @return true if the string is an Integer, false otherwise
*/
public static boolean isInt(String string) {
try {
Integer.parseInt(string);
return true;
}
catch (NumberFormatException nFE) {
} catch (NumberFormatException nFE) {
return false;
}
}
@@ -93,15 +137,15 @@ public class StringUtils {
/**
* Determine if a string represents a Double
*
* @param string String to check
* @param string
* String to check
* @return true if the string is a Double, false otherwise
*/
public static boolean isDouble(String string) {
try {
Double.parseDouble(string);
return true;
}
catch (NumberFormatException nFE) {
} catch (NumberFormatException nFE) {
return false;
}
}

View File

@@ -0,0 +1,36 @@
package com.gmail.nossr50.util.adapter;
import org.bukkit.block.Biome;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.Set;
public class BiomeAdapter {
public static final Set<Biome> WATER_BIOMES;
public static final Set<Biome> ICE_BIOMES;
static {
List<Biome> allBiomes = Arrays.asList(Biome.values());
List<Biome> waterBiomes = new ArrayList<Biome>();
List<Biome> iceBiomes = new ArrayList<Biome>();
for (Biome biome : allBiomes) {
if (isWater(biome.name()) && !isCold(biome.name())) {
waterBiomes.add(biome);
} else if (isCold(biome.name())) {
iceBiomes.add(biome);
}
}
WATER_BIOMES = EnumSet.copyOf(waterBiomes);
ICE_BIOMES = EnumSet.copyOf(iceBiomes);
}
private static boolean isWater(String name) {
return name.contains("RIVER") || name.contains("OCEAN");
}
private static boolean isCold(String name) {
return (name.contains("COLD") || name.contains("ICE") || name.contains("FROZEN") || name.contains("TAIGA")) && !(name.contains("WARM"));
}
}

View File

@@ -184,9 +184,10 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public boolean isTrue(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 6;
String key = world.getName() + "," + cx + "," + cz + "," + cy;
if (!store.containsKey(key)) {
@@ -212,9 +213,9 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void setTrue(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 6;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
@@ -244,9 +245,9 @@ public class HashChunkletManager implements ChunkletManager {
@Override
public void setFalse(int x, int y, int z, World world) {
int cx = x / 16;
int cz = z / 16;
int cy = y / 64;
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 6;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;

View File

@@ -293,8 +293,9 @@ public class HashChunkManager implements ChunkManager {
return false;
}
int cx = x / 16;
int cz = z / 16;
int cx = x >> 4;
int cz = z >> 4;
String key = world.getName() + "," + cx + "," + cz;
if (!store.containsKey(key)) {
@@ -336,8 +337,8 @@ public class HashChunkManager implements ChunkManager {
return;
}
int cx = x / 16;
int cz = z / 16;
int cx = x >> 4;
int cz = z >> 4;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;
@@ -382,8 +383,8 @@ public class HashChunkManager implements ChunkManager {
return;
}
int cx = x / 16;
int cz = z / 16;
int cx = x >> 4;
int cz = z >> 4;
int ix = Math.abs(x) % 16;
int iz = Math.abs(z) % 16;

View File

@@ -5,9 +5,9 @@ import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.World;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.blockmeta.ChunkletStore;
public class PrimitiveChunkStore implements ChunkStore {
@@ -20,14 +20,12 @@ public class PrimitiveChunkStore implements ChunkStore {
private int cx;
private int cz;
private UUID worldUid;
transient private int worldHeight;
public PrimitiveChunkStore(World world, int cx, int cz) {
this.cx = cx;
this.cz = cz;
this.worldUid = world.getUID();
this.worldHeight = world.getMaxHeight();
this.store = new boolean[16][16][this.worldHeight];
this.store = new boolean[16][16][world.getMaxHeight()];
}
@Override
@@ -57,12 +55,16 @@ public class PrimitiveChunkStore implements ChunkStore {
@Override
public void setTrue(int x, int y, int z) {
if (y >= store[0][0].length || y < 0)
return;
store[x][z][y] = true;
dirty = true;
}
@Override
public void setFalse(int x, int y, int z) {
if (y >= store[0][0].length || y < 0)
return;
store[x][z][y] = false;
dirty = true;
}
@@ -71,7 +73,7 @@ public class PrimitiveChunkStore implements ChunkStore {
public boolean isEmpty() {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
for (int y = 0; y < store[0][0].length; y++) {
if (store[x][z][y]) {
return false;
}
@@ -85,7 +87,7 @@ public class PrimitiveChunkStore implements ChunkStore {
public void copyFrom(ChunkletStore otherStore) {
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
for (int y = 0; y < store[0][0].length; y++) {
store[x][z][y] = otherStore.isTrue(x, y, z);
}
}
@@ -121,11 +123,6 @@ public class PrimitiveChunkStore implements ChunkStore {
cx = in.readInt();
cz = in.readInt();
// Constructor is not invoked, need to set these fields
World world = mcMMO.p.getServer().getWorld(this.worldUid);
this.worldHeight = world.getMaxHeight();
store = (boolean[][][]) in.readObject();
if (fileVersionNumber < 5) {
@@ -136,10 +133,10 @@ public class PrimitiveChunkStore implements ChunkStore {
private void fixArray() {
boolean[][][] temp = this.store;
this.store = new boolean[16][16][this.worldHeight];
this.store = new boolean[16][16][Bukkit.getWorld(worldUid).getMaxHeight()];
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
for (int y = 0; y < this.worldHeight; y++) {
for (int y = 0; y < store[0][0].length; y++) {
try {
store[x][z][y] = temp[x][y][z];
}

View File

@@ -7,6 +7,7 @@ import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.KrakenCommand;
import com.gmail.nossr50.commands.MHDCommand;
import com.gmail.nossr50.commands.McImportCommand;
import com.gmail.nossr50.commands.McabilityCommand;
import com.gmail.nossr50.commands.McconvertCommand;
@@ -390,6 +391,15 @@ public final class CommandRegistrationManager {
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mobhealth", "<DISABLED | HEARTS | BAR>"));
command.setExecutor(new MobhealthCommand());
}
private static void registerMHDCommand() {
PluginCommand command = mcMMO.p.getCommand("mhd");
command.setDescription("Resets all mob health bar settings for all players to the default"); //TODO: Localize
command.setPermission("mcmmo.commands.mhd");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mhd"));
command.setExecutor(new MHDCommand());
}
private static void registerMcscoreboardCommand() {
PluginCommand command = mcMMO.p.getCommand("mcscoreboard");
@@ -430,6 +440,7 @@ public final class CommandRegistrationManager {
registerMcrefreshCommand();
registerMcscoreboardCommand();
registerMobhealthCommand();
registerMHDCommand();
registerXprateCommand();
// Chat Commands

View File

@@ -296,6 +296,11 @@ public final class CommandUtils {
for (OfflinePlayer offlinePlayer : mcMMO.p.getServer().getOfflinePlayers()) {
String playerName = offlinePlayer.getName();
if (playerName == null) { //Do null checking here to detect corrupted data before sending it throuogh .equals
System.err.println("[McMMO] Player data file with UIID " + offlinePlayer.getUniqueId() + " is missing a player name. This may be a legacy file from before bukkit.lastKnownName. This should be okay to ignore.");
continue; //Don't let an error here interrupt the loop
}
if (partialName.equalsIgnoreCase(playerName)) {
// Exact match

View File

@@ -52,7 +52,14 @@ public final class UserManager {
mcMMO.p.debug("Saving mcMMOPlayers... (" + onlinePlayers.size() + ")");
for (Player player : onlinePlayers) {
getPlayer(player).getProfile().save();
try
{
getPlayer(player).getProfile().save();
}
catch (Exception e)
{
mcMMO.p.getLogger().warning("Could not save mcMMO player data for player: " + player.getName());
}
}
}

View File

@@ -351,8 +351,8 @@ public class ScoreboardWrapper {
targetPlayer = null;
targetProfile = null;
int endPosition = page * 15;
int startPosition = endPosition - 14;
int endPosition = page * 10;
int startPosition = endPosition - 9;
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.POWER_LEVEL, startPosition, endPosition));
}
@@ -364,8 +364,8 @@ public class ScoreboardWrapper {
targetPlayer = null;
targetProfile = null;
int endPosition = page * 15;
int startPosition = endPosition - 14;
int endPosition = page * 10;
int startPosition = endPosition - 9;
loadObjective(String.format("%s (%2d - %2d)", ScoreboardManager.skillLabels.get(skill), startPosition, endPosition));
}

View File

@@ -4,6 +4,7 @@ import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.AnimalTamer;
import org.bukkit.entity.Animals;
@@ -13,6 +14,7 @@ import org.bukkit.entity.EntityType;
import org.bukkit.entity.Guardian;
import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.entity.Player;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Tameable;
@@ -54,6 +56,10 @@ public final class CombatUtils {
private CombatUtils() {}
private static void processSwordCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
SwordsManager swordsManager = mcMMOPlayer.getSwordsManager();
double initialDamage = event.getDamage();
@@ -75,6 +81,10 @@ public final class CombatUtils {
}
private static void processAxeCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
Map<DamageModifier, Double> modifiers = getModifiers(event);
@@ -110,6 +120,10 @@ public final class CombatUtils {
}
private static void processUnarmedCombat(LivingEntity target, Player player, EntityDamageByEntityEvent event) {
if (event.getCause() == DamageCause.THORNS) {
return;
}
double initialDamage = event.getDamage();
double finalDamage = initialDamage;
@@ -214,7 +228,7 @@ public final class CombatUtils {
return;
}
ItemStack heldItem = player.getItemInHand();
ItemStack heldItem = player.getInventory().getItemInMainHand();
if (target instanceof Tameable) {
if (heldItem.getType() == Material.BONE) {
@@ -308,7 +322,7 @@ public final class CombatUtils {
event.setDamage(acrobaticsManager.dodgeCheck(event.getDamage()));
}
if (ItemUtils.isSword(player.getItemInHand())) {
if (ItemUtils.isSword(player.getInventory().getItemInMainHand())) {
if (!SkillType.SWORDS.shouldProcess(target)) {
return;
}
@@ -386,7 +400,7 @@ public final class CombatUtils {
* @param type The type of skill being used
*/
public static void applyAbilityAoE(Player attacker, LivingEntity target, double damage, Map<DamageModifier, Double> modifiers, SkillType type) {
int numberOfTargets = getTier(attacker.getItemInHand()); // The higher the weapon tier, the more targets you hit
int numberOfTargets = getTier(attacker.getInventory().getItemInMainHand()); // The higher the weapon tier, the more targets you hit
double damageAmount = Math.max(damage, 1);
for (Entity entity : target.getNearbyEntities(2.5, 2.5, 2.5)) {
@@ -458,66 +472,33 @@ public final class CombatUtils {
baseXP = mcMMO.getModManager().getEntity(target).getXpMultiplier();
}
else if (target instanceof Animals) {
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getAnimalsXP(type);
}
else if (target instanceof Monster)
{
EntityType type = target.getType();
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
else {
EntityType type = target.getType();
switch (type) {
case BAT:
case SQUID:
case RABBIT:
baseXP = ExperienceConfig.getInstance().getAnimalsXP();
break;
case BLAZE:
case CAVE_SPIDER:
case CREEPER:
case ENDER_DRAGON:
case ENDERMAN:
case GHAST:
case GIANT:
case MAGMA_CUBE:
case PIG_ZOMBIE:
case SILVERFISH:
case SLIME:
case SPIDER:
case WITCH:
case WITHER:
case ZOMBIE:
case ENDERMITE:
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
break;
case SKELETON:
switch (((Skeleton) target).getSkeletonType()) {
case WITHER:
baseXP = ExperienceConfig.getInstance().getWitherSkeletonXP();
break;
default:
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
break;
}
break;
case IRON_GOLEM:
if (ExperienceConfig.getInstance().hasCombatXP(type)) {
if (type == EntityType.IRON_GOLEM)
{
if (!((IronGolem) target).isPlayerCreated()) {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
break;
case GUARDIAN:
if (((Guardian) target).isElder()) {
baseXP = ExperienceConfig.getInstance().getElderGuardianXP();
} else {
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
break;
default:
baseXP = 1.0;
mcMMO.getModManager().addCustomEntity(target);
break;
}
else
{
baseXP = ExperienceConfig.getInstance().getCombatXP(type);
}
}
else
{
baseXP = 1.0;
mcMMO.getModManager().addCustomEntity(target);
}
}
@@ -564,6 +545,11 @@ public final class CombatUtils {
if (!player.canSee(defender)) {
return false;
}
// Spectators should not be affected
if (defender.getGameMode() == GameMode.SPECTATOR) {
return false;
}
// It may seem a bit redundant but we need a check here to prevent bleed from being applied in applyAbilityAoE()
if (callFakeDamageEvent(player, entity, 1.0) == 0) {

View File

@@ -14,7 +14,9 @@ import org.bukkit.entity.Firework;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.metadata.FixedMetadataValue;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.config.Config;
public final class ParticleEffectUtils {
@@ -105,6 +107,7 @@ public final class ParticleEffectUtils {
location.setPitch(-90);
Firework firework = (Firework) player.getWorld().spawnEntity(location, EntityType.FIREWORK);
firework.setMetadata(mcMMO.funfettiMetadataKey, new FixedMetadataValue(mcMMO.p, null));
FireworkMeta fireworkMeta = firework.getFireworkMeta();
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(color).with((Config.getInstance().getLargeFireworks() ? Type.BALL_LARGE : Type.BALL)).trail(true).build();
fireworkMeta.addEffect(effect);

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