Fixes #3832 - Resolved issue with double drops & herbalism, similar fixes coming to woodcutting/mining soon. Reminder to update config.yml, read changelog for instructions.

If you harvest crops with a Hoe it does not require seeds to replant on successful Green Thumb
This commit is contained in:
nossr50
2019-03-23 16:21:25 -07:00
parent ce6553d857
commit 255f7bf335
13 changed files with 108 additions and 61 deletions

View File

@ -1,14 +1,19 @@
package com.gmail.nossr50.util;
import com.gmail.nossr50.config.Config;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.salvage.Salvage;
import com.gmail.nossr50.util.random.RandomChanceSkill;
import com.gmail.nossr50.util.random.RandomChanceUtil;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import java.util.HashSet;
@ -16,6 +21,34 @@ public final class BlockUtils {
private BlockUtils() {}
/**
* Mark a block for giving bonus drops, double drops are used if triple is false
* @param blockState target blockstate
* @param triple marks the block to give triple drops
*/
public static void markBlocksForBonusDrops(BlockState blockState, boolean triple)
{
if(triple)
blockState.setMetadata(mcMMO.tripleDropKey, mcMMO.metadataValue);
else
blockState.setMetadata(mcMMO.doubleDropKey, mcMMO.metadataValue);
}
/**
* Checks if a player successfully passed the double drop check
* @param blockState the blockstate
* @return true if the player succeeded in the check
*/
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType)
{
if(Config.getInstance().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType))
{
return RandomChanceUtil.checkRandomChanceExecutionSuccess(new RandomChanceSkill(player, subSkillType, true));
}
return false;
}
/**
* Checks to see if a given block awards XP.
*