add farm beacon warmup

This commit is contained in:
okx-code
2025-08-25 22:19:26 +01:00
parent fc83162773
commit c1203bd3fe
4 changed files with 22 additions and 9 deletions

View File

@@ -6,10 +6,9 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.block.Beacon;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.persistence.PersistentDataType;
public class FarmBeaconManager {
@@ -17,12 +16,14 @@ public class FarmBeaconManager {
private final int beaconRange;
private final double farmBeaconFertility;
private final double farmBeaconGrowthMultiplier;
private final long farmBeaconWarmup;
public FarmBeaconManager(NamespacedKey farmBeaconKey, int beaconRange, double farmBeaconFertility, double farmBeaconGrowthMultiplier) {
public FarmBeaconManager(NamespacedKey farmBeaconKey, int beaconRange, double farmBeaconFertility, double farmBeaconGrowthMultiplier, long farmBeaconWarmup) {
this.farmBeaconKey = farmBeaconKey;
this.beaconRange = beaconRange;
this.farmBeaconFertility = farmBeaconFertility;
this.farmBeaconGrowthMultiplier = farmBeaconGrowthMultiplier;
this.farmBeaconWarmup = farmBeaconWarmup;
}
public static FarmBeaconManager fromConfiguration(ConfigurationSection section) {
@@ -30,7 +31,8 @@ public class FarmBeaconManager {
NamespacedKey.fromString(section.getString("farm_beacon_key")),
section.getInt("farm_beacon_range"),
section.getDouble("farm_beacon_fertility"),
section.getDouble("farm_beacon_growth_multiplier")
section.getDouble("farm_beacon_growth_multiplier"),
section.getLong("farm_beacon_warmup")
);
}
@@ -57,7 +59,16 @@ public class FarmBeaconManager {
continue;
}
if (beacon.getTier() > 0 && beacon.getPersistentDataContainer().has(farmBeaconKey)) {
if (beacon.getTier() <= 0) {
continue;
}
Long value = beacon.getPersistentDataContainer().get(farmBeaconKey, PersistentDataType.LONG);
if (value == null) {
continue;
}
if (System.currentTimeMillis() - value >= farmBeaconWarmup) {
return true;
}
}

View File

@@ -186,6 +186,8 @@ climate:
farm_beacon_key: "heliodor:farm_beacon"
farm_beacon_range: 20
farm_beacon_fertility: 0.05
farm_beacon_growth_multiplier: 1
farm_beacon_warmup: 518400000
plants: