mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 12:46:46 +01:00
Make farmland keep its moisture (#3952)
Handle MoistureChangeEvent for farm land
This commit is contained in:
parent
0d359ade0c
commit
d7c2ab1d16
@ -98,6 +98,7 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.CauldronLevelChangeEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.block.MoistureChangeEvent;
|
||||
import org.bukkit.event.block.SpongeAbsorbEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
@ -703,6 +704,28 @@ public class BlockEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMoistureChange(MoistureChangeEvent event) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChange(BlockFromToEvent event) {
|
||||
Block fromBlock = event.getBlock();
|
||||
|
Loading…
Reference in New Issue
Block a user