Fixed explosions destroying too many blocks.
Due to a breaking Spigot change in 1.8.3.
This commit is contained in:
parent
1bfb57b9e0
commit
38cbab1c40
|
|
@ -52,6 +52,7 @@ import org.bukkit.entity.Villager;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||||
|
|
@ -195,21 +196,30 @@ class EntityEventHandler implements Listener
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
public void onEntityExplode(EntityExplodeEvent explodeEvent)
|
public void onEntityExplode(EntityExplodeEvent explodeEvent)
|
||||||
{
|
{
|
||||||
//only applies to claims-enabled worlds
|
this.handleExplosion(explodeEvent.getLocation(), explodeEvent.getEntity(), explodeEvent.blockList());
|
||||||
Location location = explodeEvent.getLocation();
|
}
|
||||||
World world = location.getWorld();
|
|
||||||
|
//when a block explodes...
|
||||||
if(!GriefPrevention.instance.claimsEnabledForWorld(world)) return;
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
public void onBlockExplode(BlockExplodeEvent explodeEvent)
|
||||||
//FEATURE: explosions don't destroy blocks when they explode near or above sea level in standard worlds
|
{
|
||||||
boolean isCreeper = (explodeEvent.getEntity() != null && explodeEvent.getEntity() instanceof Creeper);
|
this.handleExplosion(explodeEvent.getBlock().getLocation(), null, explodeEvent.blockList());
|
||||||
|
}
|
||||||
boolean applySeaLevelRules = world.getEnvironment() == Environment.NORMAL && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions));
|
|
||||||
|
void handleExplosion(Location location, Entity entity, List<Block> blocks)
|
||||||
List<Block> blocks = explodeEvent.blockList();
|
{
|
||||||
|
//only applies to claims-enabled worlds
|
||||||
|
World world = location.getWorld();
|
||||||
|
|
||||||
//special rule for creative worlds: explosions don't destroy anything
|
if(!GriefPrevention.instance.claimsEnabledForWorld(world)) return;
|
||||||
if(GriefPrevention.instance.creativeRulesApply(explodeEvent.getLocation()))
|
|
||||||
|
//FEATURE: explosions don't destroy surface blocks by default
|
||||||
|
boolean isCreeper = (entity != null && entity instanceof Creeper);
|
||||||
|
|
||||||
|
boolean applySurfaceRules = world.getEnvironment() == Environment.NORMAL && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions));
|
||||||
|
|
||||||
|
//special rule for creative worlds: explosions don't destroy anything
|
||||||
|
if(GriefPrevention.instance.creativeRulesApply(location))
|
||||||
{
|
{
|
||||||
for(int i = 0; i < blocks.size(); i++)
|
for(int i = 0; i < blocks.size(); i++)
|
||||||
{
|
{
|
||||||
|
|
@ -221,8 +231,8 @@ class EntityEventHandler implements Listener
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//make a list of blocks which were allowed to explode
|
//make a list of blocks which were allowed to explode
|
||||||
List<Block> explodedBlocks = new ArrayList<Block>();
|
List<Block> explodedBlocks = new ArrayList<Block>();
|
||||||
Claim cachedClaim = null;
|
Claim cachedClaim = null;
|
||||||
for(int i = 0; i < blocks.size(); i++)
|
for(int i = 0; i < blocks.size(); i++)
|
||||||
|
|
@ -253,8 +263,8 @@ class EntityEventHandler implements Listener
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if no, then also consider sea level rules
|
//if no, then also consider surface rules
|
||||||
if(applySeaLevelRules)
|
if(applySurfaceRules && claim == null)
|
||||||
{
|
{
|
||||||
if(block.getLocation().getBlockY() < GriefPrevention.instance.getSeaLevel(world) - 7)
|
if(block.getLocation().getBlockY() < GriefPrevention.instance.getSeaLevel(world) - 7)
|
||||||
{
|
{
|
||||||
|
|
@ -266,7 +276,7 @@ class EntityEventHandler implements Listener
|
||||||
//clear original damage list and replace with allowed damage list
|
//clear original damage list and replace with allowed damage list
|
||||||
blocks.clear();
|
blocks.clear();
|
||||||
blocks.addAll(explodedBlocks);
|
blocks.addAll(explodedBlocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
//when an item spawns...
|
//when an item spawns...
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user