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.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
import org.bukkit.event.entity.EntityBreakDoorEvent;
|
||||
|
|
@ -194,22 +195,31 @@ class EntityEventHandler implements Listener
|
|||
//when an entity explodes...
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onEntityExplode(EntityExplodeEvent explodeEvent)
|
||||
{
|
||||
this.handleExplosion(explodeEvent.getLocation(), explodeEvent.getEntity(), explodeEvent.blockList());
|
||||
}
|
||||
|
||||
//when a block explodes...
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onBlockExplode(BlockExplodeEvent explodeEvent)
|
||||
{
|
||||
this.handleExplosion(explodeEvent.getBlock().getLocation(), null, explodeEvent.blockList());
|
||||
}
|
||||
|
||||
void handleExplosion(Location location, Entity entity, List<Block> blocks)
|
||||
{
|
||||
//only applies to claims-enabled worlds
|
||||
Location location = explodeEvent.getLocation();
|
||||
World world = location.getWorld();
|
||||
|
||||
if(!GriefPrevention.instance.claimsEnabledForWorld(world)) return;
|
||||
|
||||
//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);
|
||||
//FEATURE: explosions don't destroy surface blocks by default
|
||||
boolean isCreeper = (entity != null && entity instanceof Creeper);
|
||||
|
||||
boolean applySeaLevelRules = world.getEnvironment() == Environment.NORMAL && ((isCreeper && GriefPrevention.instance.config_blockSurfaceCreeperExplosions) || (!isCreeper && GriefPrevention.instance.config_blockSurfaceOtherExplosions));
|
||||
|
||||
List<Block> blocks = explodeEvent.blockList();
|
||||
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(explodeEvent.getLocation()))
|
||||
if(GriefPrevention.instance.creativeRulesApply(location))
|
||||
{
|
||||
for(int i = 0; i < blocks.size(); i++)
|
||||
{
|
||||
|
|
@ -253,8 +263,8 @@ class EntityEventHandler implements Listener
|
|||
continue;
|
||||
}
|
||||
|
||||
//if no, then also consider sea level rules
|
||||
if(applySeaLevelRules)
|
||||
//if no, then also consider surface rules
|
||||
if(applySurfaceRules && claim == null)
|
||||
{
|
||||
if(block.getLocation().getBlockY() < GriefPrevention.instance.getSeaLevel(world) - 7)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user