9
0
mirror of https://github.com/Xiao-MoMi/Custom-Crops.git synced 2025-12-20 23:49:26 +00:00

Update AbstractRequirementManager.java

This commit is contained in:
XiaoMoMi
2025-08-05 21:47:57 +08:00
parent 7edc73f813
commit aea7664887

View File

@@ -41,6 +41,7 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.type.Farmland; import org.bukkit.block.data.type.Farmland;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@@ -976,9 +977,9 @@ public abstract class AbstractRequirementManager<T> implements RequirementManage
if (args instanceof Section section) { if (args instanceof Section section) {
String flyModel = section.getString("fly-model"); String flyModel = section.getString("fly-model");
String standModel = section.getString("stand-model"); String standModel = section.getString("stand-model");
double chance = section.getDouble("chance"); MathValue<T> chance = MathValue.auto(section.get("chance"));
return (context) -> { return (context) -> {
if (Math.random() > chance) return false; if (Math.random() > chance.evaluate(context)) return false;
Location location = requireNonNull(context.arg(ContextKeys.LOCATION)); Location location = requireNonNull(context.arg(ContextKeys.LOCATION));
Pos3 pos3 = Pos3.from(location); Pos3 pos3 = Pos3.from(location);
if (ConfigManager.enableScarecrow()) { if (ConfigManager.enableScarecrow()) {