geforkt von Mirrors/Paper
SPIGOT-7799, #1039: Expose explosion world interaction in EntityExplodeEvent and BlockExplodeEvent
By: antiPerson <nathat890@outlook.com>
Dieser Commit ist enthalten in:
Ursprung
abc756fce8
Commit
58999b263e
37
paper-api/src/main/java/org/bukkit/ExplosionResult.java
Normale Datei
37
paper-api/src/main/java/org/bukkit/ExplosionResult.java
Normale Datei
@ -0,0 +1,37 @@
|
|||||||
|
package org.bukkit;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the outcome of an explosion.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Experimental
|
||||||
|
public enum ExplosionResult {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an explosion where no change took place.
|
||||||
|
*
|
||||||
|
* This is the case when {@link org.bukkit.GameRule#MOB_GRIEFING} is
|
||||||
|
* disabled.
|
||||||
|
*/
|
||||||
|
KEEP,
|
||||||
|
/**
|
||||||
|
* Represents an explosion where all destroyed blocks drop their items.
|
||||||
|
*
|
||||||
|
* This is the case when
|
||||||
|
* {@link org.bukkit.GameRule#TNT_EXPLOSION_DROP_DECAY} or
|
||||||
|
* {@link org.bukkit.GameRule#BLOCK_EXPLOSION_DROP_DECAY} is disabled.
|
||||||
|
*/
|
||||||
|
DESTROY,
|
||||||
|
/**
|
||||||
|
* Represents an explosion where explosions cause only some blocks to drop.
|
||||||
|
*/
|
||||||
|
DESTROY_WITH_DECAY,
|
||||||
|
/**
|
||||||
|
* Represents an explosion where a block change/update has happened.
|
||||||
|
*
|
||||||
|
* For example, when a wind charge is used it will cause nearby buttons,
|
||||||
|
* levers and bells to be activated.
|
||||||
|
*/
|
||||||
|
TRIGGER_BLOCK
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package org.bukkit.event.block;
|
package org.bukkit.event.block;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.ExplosionResult;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
@ -20,18 +21,15 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|||||||
private final BlockState blockState;
|
private final BlockState blockState;
|
||||||
private final List<Block> blocks;
|
private final List<Block> blocks;
|
||||||
private float yield;
|
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);
|
super(what);
|
||||||
this.blockState = blockState;
|
this.blockState = blockState;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.yield = yield;
|
this.yield = yield;
|
||||||
this.cancel = false;
|
this.cancel = false;
|
||||||
}
|
this.result = result;
|
||||||
|
|
||||||
@Deprecated(forRemoval = true)
|
|
||||||
public BlockExplodeEvent(@NotNull final Block what, @NotNull final List<Block> blocks, final float yield) {
|
|
||||||
this(what, what.getState(), blocks, yield);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,6 +42,16 @@ public class BlockExplodeEvent extends BlockEvent implements Cancellable {
|
|||||||
this.cancel = cancel;
|
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.
|
* Returns the captured BlockState of the block that exploded.
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.bukkit.event.entity;
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.bukkit.ExplosionResult;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -17,13 +18,15 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
|
|||||||
private final Location location;
|
private final Location location;
|
||||||
private final List<Block> blocks;
|
private final List<Block> blocks;
|
||||||
private float yield;
|
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);
|
super(what);
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.yield = yield;
|
this.yield = yield;
|
||||||
this.cancel = false;
|
this.cancel = false;
|
||||||
|
this.result = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -36,6 +39,16 @@ public class EntityExplodeEvent extends EntityEvent implements Cancellable {
|
|||||||
this.cancel = cancel;
|
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
|
* Returns the list of blocks that would have been removed or were removed
|
||||||
* from the explosion event.
|
* from the explosion event.
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren