mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Prevent NPE in entityDamage
This is done by creating a fake (WE) entity type in the case that the entity type name is null. In these cases, WE has no equivalent. By doing this, all entity category contains check will fail, and it will default to the PVE check at the bottom of the if-else if chain.
This commit is contained in:
parent
e8dd5fe903
commit
10dbcbcdbd
@ -225,6 +225,9 @@ import java.util.regex.Pattern;
|
||||
@SuppressWarnings("unused")
|
||||
public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
public static final com.sk89q.worldedit.world.entity.EntityType FAKE_ENTITY_TYPE
|
||||
= new com.sk89q.worldedit.world.entity.EntityType("plotsquared:fake");
|
||||
|
||||
private boolean pistonBlocks = true;
|
||||
private float lastRadius;
|
||||
// To prevent recursion
|
||||
@ -2751,8 +2754,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
if (player != null) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
final com.sk89q.worldedit.world.entity.EntityType entityType =
|
||||
BukkitAdapter.adapt(victim.getType());
|
||||
|
||||
final com.sk89q.worldedit.world.entity.EntityType entityType;
|
||||
|
||||
// Create a fake entity type if the type does not have a name
|
||||
if (victim.getType().getName() == null) {
|
||||
entityType = FAKE_ENTITY_TYPE;
|
||||
} else {
|
||||
entityType = BukkitAdapter.adapt(victim.getType());
|
||||
}
|
||||
|
||||
if (EntityCategories.HANGING.contains(entityType)) { // hanging
|
||||
if (plot != null && (plot.getFlag(HangingBreakFlag.class)) || plot
|
||||
.isAdded(plotPlayer.getUUID())) {
|
||||
|
Loading…
Reference in New Issue
Block a user