Prevent trees from extending out of warzone

Closes #799
This commit is contained in:
cmastudios 2014-06-12 19:12:42 -05:00
parent 382261eb83
commit bdc961c7e1
1 changed files with 15 additions and 0 deletions

View File

@ -4,9 +4,11 @@ import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
@ -14,6 +16,7 @@ import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
import org.bukkit.event.block.BlockPistonRetractEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.ItemStack;
import org.getspout.spoutapi.SpoutManager;
import org.getspout.spoutapi.player.SpoutPlayer;
@ -460,4 +463,16 @@ public class WarBlockListener implements Listener {
return;
}
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onStructureGrowth(final StructureGrowEvent event) {
Warzone zone = Warzone.getZoneByLocation(event.getLocation());
if (zone != null) {
for (BlockState state : event.getBlocks()) {
if (!zone.getVolume().contains(state.getLocation())) {
state.setType(Material.AIR);
}
}
}
}
}