|
18 | 18 | import org.bukkit.event.EventPriority; |
19 | 19 | import org.bukkit.event.Listener; |
20 | 20 | import org.bukkit.event.block.BlockBreakEvent; |
| 21 | +import org.bukkit.event.block.BlockFromToEvent; |
21 | 22 | import org.bukkit.event.block.BlockPlaceEvent; |
22 | 23 | import org.bukkit.event.entity.CreatureSpawnEvent; |
23 | 24 | import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; |
|
37 | 38 | import org.bukkit.event.vehicle.VehicleEnterEvent; |
38 | 39 | import org.bukkit.event.weather.WeatherChangeEvent; |
39 | 40 | import org.bukkit.plugin.Plugin; |
40 | | - |
41 | 41 | import org.mctourney.autoreferee.AutoRefMatch; |
42 | 42 | import org.mctourney.autoreferee.AutoRefPlayer; |
43 | 43 | import org.mctourney.autoreferee.AutoRefTeam; |
@@ -318,6 +318,33 @@ public void blockInteract(PlayerInteractEvent event) |
318 | 318 | } |
319 | 319 | } |
320 | 320 |
|
| 321 | + /* |
| 322 | + * Prevents liquids from flowing in regions flagged with NO_FLOW |
| 323 | + */ |
| 324 | + @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) |
| 325 | + public void onBlockFromTo(BlockFromToEvent event) { |
| 326 | + Block block = event.getToBlock(); |
| 327 | + AutoRefMatch match = plugin.getMatch(block.getWorld()); |
| 328 | + |
| 329 | + if (match == null) return; |
| 330 | + |
| 331 | + Location location = block.getLocation(); |
| 332 | + |
| 333 | + // .getToBlock() is strange so we must correct the block's location |
| 334 | + switch (event.getFace()) { |
| 335 | + case EAST: |
| 336 | + location = location.add(1d, 0d, 0d); |
| 337 | + case SOUTH: |
| 338 | + location = location.add(0d, 0d, 1d); |
| 339 | + default: |
| 340 | + break; |
| 341 | + } |
| 342 | + |
| 343 | + if (match.hasFlag(location, AutoRefRegion.Flag.NO_FLOW)) { |
| 344 | + event.setCancelled(true); return; |
| 345 | + } |
| 346 | + } |
| 347 | + |
321 | 348 | @EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true) |
322 | 349 | public void entityInteract(PlayerInteractEntityEvent event) |
323 | 350 | { |
|
0 commit comments