mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2026-02-21 11:13:00 +01:00
Fixed possible NPE in our events, and BrewingStands now remember who last interacted with them, this allows for hoppers to be used with Alchemy Fixes #5004 Fixes #4958 Fixes #4641
This commit is contained in:
@@ -2,11 +2,13 @@ package com.gmail.nossr50.util;
|
||||
|
||||
import com.gmail.nossr50.config.experience.ExperienceConfig;
|
||||
import com.gmail.nossr50.datatypes.meta.BonusDropMeta;
|
||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||
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.player.UserManager;
|
||||
import com.gmail.nossr50.util.random.ProbabilityUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -16,9 +18,12 @@ import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
public final class BlockUtils {
|
||||
|
||||
public static final String SHORT_GRASS = "SHORT_GRASS";
|
||||
@@ -94,10 +99,28 @@ public final class BlockUtils {
|
||||
*
|
||||
* @param blockState the blockstate
|
||||
* @return true if the player succeeded in the check
|
||||
* @deprecated Use {@link #checkDoubleDrops(McMMOPlayer, BlockState, SubSkillType)} instead
|
||||
*/
|
||||
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType skillType, SubSkillType subSkillType) {
|
||||
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(skillType, blockState.getType()) && Permissions.isSubSkillEnabled(player, subSkillType)) {
|
||||
return ProbabilityUtil.isSkillRNGSuccessful(subSkillType, player);
|
||||
@Deprecated(forRemoval = true, since = "2.2.010")
|
||||
public static boolean checkDoubleDrops(Player player, BlockState blockState, PrimarySkillType ignored, SubSkillType subSkillType) {
|
||||
return checkDoubleDrops(UserManager.getPlayer(player), blockState, subSkillType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player successfully passed the double drop check
|
||||
*
|
||||
* @param mmoPlayer the player involved in the check
|
||||
* @param blockState the blockstate of the block
|
||||
* @param subSkillType the subskill involved
|
||||
* @return true if the player succeeded in the check
|
||||
*/
|
||||
public static boolean checkDoubleDrops(@Nullable McMMOPlayer mmoPlayer, @NotNull BlockState blockState,
|
||||
@NotNull SubSkillType subSkillType) {
|
||||
requireNonNull(blockState, "blockState cannot be null");
|
||||
requireNonNull(subSkillType, "subSkillType cannot be null");
|
||||
if (mcMMO.p.getGeneralConfig().getDoubleDropsEnabled(subSkillType.getParentSkill(), blockState.getType())
|
||||
&& Permissions.isSubSkillEnabled(mmoPlayer, subSkillType)) {
|
||||
return ProbabilityUtil.isSkillRNGSuccessful(subSkillType, mmoPlayer);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user