Add snow-form flag

This commit is contained in:
Jesse Boyd 2016-09-27 01:38:59 +10:00
parent 177b33154f
commit b6df07f723
2 changed files with 23 additions and 0 deletions

View File

@ -73,6 +73,7 @@ import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFormEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockIgniteEvent;
@ -833,6 +834,27 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockFormEvent event) {
Block block = event.getBlock();
Location location = BukkitUtil.getLocation(block.getLocation());
if (location.isPlotRoad()) {
event.setCancelled(true);
return;
}
PlotArea area = location.getPlotArea();
if (area == null) {
return;
}
Plot plot = area.getOwnedPlot(location);
if (plot == null) {
return;
}
if (Flags.SNOW_FORM.isFalse(plot)) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDamage(BlockDamageEvent event) {
Player player = event.getPlayer();

View File

@ -50,6 +50,7 @@ public final class Flags {
public static final BooleanFlag DISABLE_PHYSICS = new BooleanFlag("disable-physics");
public static final BooleanFlag LIQUID_FLOW = new BooleanFlag("liquid-flow");
public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt");
public static final BooleanFlag SNOW_FORM = new BooleanFlag("snow-form");
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
public static final BooleanFlag BLOCK_BURN = new BooleanFlag("block-burn");