44import static com .gmail .nossr50 .util .ItemUtils .removeItemIncludingOffHand ;
55import static com .gmail .nossr50 .util .Misc .TICK_CONVERSION_FACTOR ;
66import static com .gmail .nossr50 .util .Misc .getBlockCenter ;
7+ import static com .gmail .nossr50 .util .Permissions .isSubSkillEnabled ;
8+ import static com .gmail .nossr50 .util .skills .RankUtils .hasUnlockedSubskill ;
79import static com .gmail .nossr50 .util .text .ConfigStringUtils .getMaterialConfigString ;
810import static java .util .Objects .requireNonNull ;
911
3032import com .gmail .nossr50 .util .EventUtils ;
3133import com .gmail .nossr50 .util .ItemUtils ;
3234import com .gmail .nossr50 .util .MetadataConstants ;
33- import com .gmail .nossr50 .util .Misc ;
3435import com .gmail .nossr50 .util .Permissions ;
3536import com .gmail .nossr50 .util .player .NotificationManager ;
3637import com .gmail .nossr50 .util .random .ProbabilityUtil ;
6263public class HerbalismManager extends SkillManager {
6364 private final static HashMap <String , Integer > plantBreakLimits ;
6465
65- private static final String CACTUS_STR = "cactus" ;
66+ private static final String CACTUS_ID = "cactus" ;
6667 private static final String CACTUS_FLOWER_STR = "cactus_flower" ;
68+ private static final String BAMBOO_ID = "bamboo" ;
69+ private static final String SUGAR_CANE_ID = "sugar_cane" ;
70+ private static final String KELP_ID = "kelp" ;
71+ private static final String KELP_PLANT_ID = "kelp_plant" ;
72+ private static final String CHORUS_PLANT_ID = "chorus_plant" ;
73+ private static final String SWEET_BERRY_BUSH_ID = "sweet_berry_bush" ;
6774
6875 static {
6976 plantBreakLimits = new HashMap <>();
70- plantBreakLimits .put (CACTUS_STR , 3 );
71- plantBreakLimits .put ("bamboo" , 20 );
72- plantBreakLimits .put ("sugar_cane" , 3 );
73- plantBreakLimits .put ("kelp" , 26 );
74- plantBreakLimits .put ("kelp_plant" , 26 );
75- plantBreakLimits .put ("chorus_plant" , 22 );
77+ plantBreakLimits .put (CACTUS_ID , 3 );
78+ plantBreakLimits .put (BAMBOO_ID , 20 );
79+ plantBreakLimits .put (SUGAR_CANE_ID , 3 );
80+ plantBreakLimits .put (KELP_ID , 26 );
81+ plantBreakLimits .put (KELP_PLANT_ID , 26 );
82+ plantBreakLimits .put (CHORUS_PLANT_ID , 22 );
7683 }
7784
7885 public HerbalismManager (McMMOPlayer mmoPlayer ) {
7986 super (mmoPlayer , PrimarySkillType .HERBALISM );
8087 }
8188
8289 public boolean canGreenThumbBlock (BlockState blockState ) {
83- if (!RankUtils . hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_GREEN_THUMB )) {
90+ if (!hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_GREEN_THUMB )) {
8491 return false ;
8592 }
8693
@@ -98,7 +105,7 @@ public boolean canUseShroomThumb(BlockState blockState) {
98105 return false ;
99106 }
100107
101- if (!RankUtils . hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_SHROOM_THUMB )) {
108+ if (!hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_SHROOM_THUMB )) {
102109 return false ;
103110 }
104111
@@ -110,12 +117,12 @@ public boolean canUseShroomThumb(BlockState blockState) {
110117 || itemType == Material .RED_MUSHROOM )
111118 && inventory .contains (Material .BROWN_MUSHROOM , 1 )
112119 && inventory .contains (Material .RED_MUSHROOM , 1 )
113- && Permissions . isSubSkillEnabled (player , SubSkillType .HERBALISM_SHROOM_THUMB );
120+ && isSubSkillEnabled (player , SubSkillType .HERBALISM_SHROOM_THUMB );
114121 }
115122
116123 public void processBerryBushHarvesting (@ NotNull BlockState blockState ) {
117124 /* Check if the player is harvesting a berry bush */
118- if (blockState .getType ().toString ().equalsIgnoreCase ("sweet_berry_bush" )) {
125+ if (blockState .getType ().toString ().equalsIgnoreCase (SWEET_BERRY_BUSH_ID )) {
119126 if (mmoPlayer .isDebugMode ()) {
120127 mmoPlayer .getPlayer ().sendMessage ("Processing sweet berry bush rewards" );
121128 }
@@ -167,7 +174,7 @@ public CheckBushAge(@NotNull Block block, @NotNull McMMOPlayer mmoPlayer, int xp
167174 public void run () {
168175 BlockState blockState = block .getState ();
169176
170- if (blockState .getType ().toString ().equalsIgnoreCase ("sweet_berry_bush" )) {
177+ if (blockState .getType ().toString ().equalsIgnoreCase (SWEET_BERRY_BUSH_ID )) {
171178 if (blockState .getBlockData () instanceof Ageable ageable ) {
172179
173180 if (ageable .getAge () <= 1 ) {
@@ -180,16 +187,16 @@ public void run() {
180187
181188
182189 public boolean canUseHylianLuck () {
183- if (!RankUtils . hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_HYLIAN_LUCK )) {
190+ if (!hasUnlockedSubskill (getPlayer (), SubSkillType .HERBALISM_HYLIAN_LUCK )) {
184191 return false ;
185192 }
186193
187- return Permissions . isSubSkillEnabled (getPlayer (), SubSkillType .HERBALISM_HYLIAN_LUCK );
194+ return isSubSkillEnabled (getPlayer (), SubSkillType .HERBALISM_HYLIAN_LUCK );
188195 }
189196
190197 public boolean canActivateAbility () {
191- return mmoPlayer .getToolPreparationMode (ToolType .HOE ) && Permissions . greenTerra (
192- getPlayer ());
198+ return mmoPlayer .getToolPreparationMode (ToolType .HOE )
199+ && Permissions . greenTerra ( getPlayer ());
193200 }
194201
195202 public boolean isGreenTerraActive () {
@@ -379,8 +386,8 @@ private void processHerbalismOnBlocksBroken(BlockBreakEvent blockBreakEvent,
379386 public void checkDoubleDropsOnBrokenPlants (Player player , Collection <Block > brokenPlants ) {
380387
381388 //Only proceed if skill unlocked and permission enabled
382- if (!RankUtils . hasUnlockedSubskill (player , SubSkillType .HERBALISM_DOUBLE_DROPS )
383- || !Permissions . isSubSkillEnabled (player , SubSkillType .HERBALISM_DOUBLE_DROPS )) {
389+ if (!hasUnlockedSubskill (player , SubSkillType .HERBALISM_DOUBLE_DROPS )
390+ || !isSubSkillEnabled (player , SubSkillType .HERBALISM_DOUBLE_DROPS )) {
384391 return ;
385392 }
386393
@@ -470,7 +477,7 @@ public void awardXPForPlantBlocks(HashSet<Block> brokenPlants) {
470477 /*
471478 * Unnatural Blocks
472479 */
473- //If its a Crop we need to reward XP when its fully grown
480+ //If it's a Crop we need to reward XP when its fully grown
474481 if (isAgeableAndFullyMature (plantData ) && !isBizarreAgeable (plantData )) {
475482 xpToReward += ExperienceConfig .getInstance ()
476483 .getXp (PrimarySkillType .HERBALISM , brokenBlockNewState .getType ());
@@ -660,7 +667,7 @@ private void addCactusBlocks(Block currentBlock, Set<Block> traversed) {
660667 }
661668
662669 private boolean isCactus (Material material ) {
663- return material .getKey ().getKey ().equalsIgnoreCase (CACTUS_STR )
670+ return material .getKey ().getKey ().equalsIgnoreCase (CACTUS_ID )
664671 || material .getKey ().getKey ().equalsIgnoreCase (CACTUS_FLOWER_STR );
665672 }
666673
@@ -799,7 +806,6 @@ public boolean processShroomThumb(BlockState blockState) {
799806
800807 playerInventory .removeItem (new ItemStack (Material .BROWN_MUSHROOM ));
801808 playerInventory .removeItem (new ItemStack (Material .RED_MUSHROOM ));
802- getPlayer ().updateInventory ();
803809
804810 if (!ProbabilityUtil .isSkillRNGSuccessful (SubSkillType .HERBALISM_SHROOM_THUMB , mmoPlayer )) {
805811 NotificationManager .sendPlayerInformation (getPlayer (),
0 commit comments