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.BlockState;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.block.data.type.Dispenser;
|
import org.bukkit.block.data.type.Dispenser;
|
||||||
|
import org.bukkit.block.data.type.Farmland;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Fireball;
|
import org.bukkit.entity.Fireball;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -709,22 +710,35 @@ public class BlockEventListener implements Listener {
|
|||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location location = BukkitUtil.adapt(block.getLocation());
|
Location location = BukkitUtil.adapt(block.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
|
|
||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plot plot = area.getOwnedPlot(location);
|
Plot plot = area.getOwnedPlot(location);
|
||||||
|
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Material blockType = block.getType();
|
|
||||||
if (blockType == Material.FARMLAND) {
|
if (block.getBlockData() instanceof Farmland farmland && event.getNewState().getBlockData() instanceof Farmland newFarmland) {
|
||||||
if (!plot.getFlag(SoilDryFlag.class)) {
|
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");
|
plot.debug("Soil could not dry because soil-dry = false");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onChange(BlockFromToEvent event) {
|
public void onChange(BlockFromToEvent event) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user