mirror of https://github.com/taoneill/war.git
Fix #838, prevent growth from occupying structures
This prevents leaves/mushroom/etc from growing inside flags, monuments, cakes, bombs, spawns, etc. Trees can still be grown around the perimeter of such strucures, but all blocks generated will be in breakable areas.
This commit is contained in:
parent
00ec38c739
commit
c5adfa7023
|
@ -1,5 +1,8 @@
|
|||
package com.tommytony.war.event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -466,11 +469,16 @@ public class WarBlockListener implements Listener {
|
|||
public void onStructureGrowth(final StructureGrowEvent event) {
|
||||
Warzone zone = Warzone.getZoneByLocation(event.getLocation());
|
||||
if (zone != null) {
|
||||
List<BlockState> canceledBlocks = new ArrayList<BlockState>();
|
||||
for (BlockState state : event.getBlocks()) {
|
||||
if (!zone.getVolume().contains(state.getLocation())) {
|
||||
state.setType(Material.AIR);
|
||||
if (!zone.getVolume().contains(state.getLocation())
|
||||
|| zone.isImportantBlock(state.getBlock())) {
|
||||
canceledBlocks.add(state);
|
||||
}
|
||||
}
|
||||
for (BlockState state : canceledBlocks) {
|
||||
event.getBlocks().remove(state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue