SPIGOT-7799, #1039: Expose explosion world interaction in EntityExplodeEvent and BlockExplodeEvent
By: antiPerson <nathat890@outlook.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.block;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.ExplosionResult;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -20,18 +21,15 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
||||
private final BlockState blockState;
|
||||
private final List<Block> blocks;
|
||||
private float yield;
|
||||
private final ExplosionResult result;
|
||||
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final BlockState blockState, @NotNull final List<Block> blocks, final float yield) {
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final BlockState blockState, @NotNull final List<Block> blocks, final float yield, @NotNull final ExplosionResult result) {
|
||||
super(what);
|
||||
this.blockState = blockState;
|
||||
this.blocks = blocks;
|
||||
this.yield = yield;
|
||||
this.cancel = false;
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
|
||||
this(what, what.getState(), blocks, yield);
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,6 +42,16 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of the explosion if it is not cancelled.
|
||||
*
|
||||
* @return the result of the explosion
|
||||
*/
|
||||
@NotNull
|
||||
public ExplosionResult getExplosionResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the captured BlockState of the block that exploded.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.ExplosionResult;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -17,13 +18,15 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
|
||||
private final Location location;
|
||||
private final List<Block> blocks;
|
||||
private float yield;
|
||||
private final ExplosionResult result;
|
||||
|
||||
public EntityExplodeEvent(@NotNull final Entity what, @NotNull final Location location, @NotNull final List<Block> blocks, final float yield) {
|
||||
public EntityExplodeEvent(@NotNull final Entity what, @NotNull final Location location, @NotNull final List<Block> blocks, final float yield, @NotNull final ExplosionResult result) {
|
||||
super(what);
|
||||
this.location = location;
|
||||
this.blocks = blocks;
|
||||
this.yield = yield;
|
||||
this.cancel = false;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -36,6 +39,16 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the result of the explosion if it is not cancelled.
|
||||
*
|
||||
* @return the result of the explosion
|
||||
*/
|
||||
@NotNull
|
||||
public ExplosionResult getExplosionResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of blocks that would have been removed or were removed
|
||||
* from the explosion event.
|
||||
|
||||
Reference in New Issue
Block a user