mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-01-18 08:25:26 +01:00
Fix farmland moisturize (#3978)
* fix: Fix farmland gets moisturizes Signed-off-by: ByteExceptionM <git@byteexception.eu> * chore: Revert code reformat Signed-off-by: ByteExceptionM <git@byteexception.eu> --------- Signed-off-by: ByteExceptionM <git@byteexception.eu>
This commit is contained in:
parent
c46cc73f52
commit
fc3137cd96
@ -71,6 +71,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.type.Dispenser;
|
||||
import org.bukkit.block.data.type.Farmland;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -709,20 +710,33 @@ public class BlockEventListener implements Listener {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.adapt(block.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
|
||||
if (plot == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Material blockType = block.getType();
|
||||
if (blockType == Material.FARMLAND) {
|
||||
if (!plot.getFlag(SoilDryFlag.class)) {
|
||||
plot.debug("Soil could not dry because soil-dry = false");
|
||||
event.setCancelled(true);
|
||||
|
||||
if (block.getBlockData() instanceof Farmland farmland && event.getNewState().getBlockData() instanceof Farmland newFarmland) {
|
||||
int currentMoisture = farmland.getMoisture();
|
||||
int newMoisture = newFarmland.getMoisture();
|
||||
|
||||
// farmland gets moisturizes
|
||||
if (newMoisture > currentMoisture) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plot.getFlag(SoilDryFlag.class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plot.debug("Soil could not dry because soil-dry = false");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user