mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-25 18:47:44 +01:00
Destroy fire blocks when fire-spread is disallowed
This commit is contained in:
parent
0bcf4b3597
commit
1463547af4
@ -24,6 +24,7 @@
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -296,7 +297,6 @@ public void onBlockIgnite(BlockIgniteEvent event) {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
boolean isFireSpread = cause == IgniteCause.SPREAD;
|
||||||
|
|
||||||
if (wcfg.preventLightningFire && cause == IgniteCause.LIGHTNING) {
|
if (wcfg.preventLightningFire && cause == IgniteCause.LIGHTNING) {
|
||||||
@ -402,7 +402,9 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (wcfg.fireSpreadDisableToggle) {
|
if (wcfg.fireSpreadDisableToggle) {
|
||||||
|
Block block = event.getBlock();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,6 +413,7 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
|
|
||||||
if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) {
|
if (wcfg.disableFireSpreadBlocks.contains(block.getTypeId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), BlockID.FIRE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -422,11 +425,15 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
|
|
||||||
if (wcfg.useRegions) {
|
if (wcfg.useRegions) {
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
|
int x = block.getX();
|
||||||
|
int y = block.getY();
|
||||||
|
int z = block.getZ();
|
||||||
Vector pt = toVector(block);
|
Vector pt = toVector(block);
|
||||||
RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld());
|
RegionManager mgr = plugin.getGlobalRegionManager().get(block.getWorld());
|
||||||
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
ApplicableRegionSet set = mgr.getApplicableRegions(pt);
|
||||||
|
|
||||||
if (!set.allows(DefaultFlag.FIRE_SPREAD)) {
|
if (!set.allows(DefaultFlag.FIRE_SPREAD)) {
|
||||||
|
checkAndDestroyAround(block.getWorld(), x, y, z, BlockID.FIRE);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -434,6 +441,21 @@ public void onBlockBurn(BlockBurnEvent event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAndDestroyAround(World world, int x, int y, int z, int required) {
|
||||||
|
checkAndDestroy(world, x, y, z + 1, required);
|
||||||
|
checkAndDestroy(world, x, y, z - 1, required);
|
||||||
|
checkAndDestroy(world, x, y + 1, z, required);
|
||||||
|
checkAndDestroy(world, x, y - 1, z, required);
|
||||||
|
checkAndDestroy(world, x + 1, y, z, required);
|
||||||
|
checkAndDestroy(world, x - 1, y, z, required);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkAndDestroy(World world, int x, int y, int z, int required) {
|
||||||
|
if (world.getBlockTypeIdAt(x, y, z) == required) {
|
||||||
|
world.getBlockAt(x, y, z).setTypeId(BlockID.AIR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Called when block physics occurs.
|
* Called when block physics occurs.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user