Fix liquid-flow

This commit is contained in:
Alexander Söderberg 2020-04-08 17:01:41 +02:00
parent f6332d2cd9
commit 616d22ceac

View File

@ -1439,6 +1439,18 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChange(BlockFromToEvent event) {
Block from = event.getBlock();
// Check liquid flow flag inside of origin plot too
final Location fLocation = BukkitUtil.getLocation(from.getLocation());
final PlotArea fromArea = fLocation.getPlotArea();
if (fromArea != null) {
final Plot plot = fromArea.getOwnedPlot(fLocation);
if (plot != null && !plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
event.setCancelled(true);
return;
}
}
Block to = event.getToBlock();
Location tLocation = BukkitUtil.getLocation(to.getLocation());
PlotArea area = tLocation.getPlotArea();
@ -1446,7 +1458,6 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
Plot plot = area.getOwnedPlot(tLocation);
Location fLocation = BukkitUtil.getLocation(from.getLocation());
if (plot != null) {
if (plot.getFlag(DisablePhysicsFlag.class)) {
event.setCancelled(true);
@ -1456,13 +1467,9 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true);
return;
}
if (!plot.getFlag(LiquidFlowFlag.class)) {
switch (to.getType()) {
case WATER:
case LAVA:
if (!plot.getFlag(LiquidFlowFlag.class) && event.getBlock().isLiquid()) {
event.setCancelled(true);
}
}
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
.equals(null, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);