Add list of entities to EntityTransformEvent

By: nathat890 <nathat890@outlook.com>
This commit is contained in:
Bukkit/Spigot 2018-12-05 09:36:23 +11:00
parent fe1baedce4
commit 83e42118d5
2 changed files with 21 additions and 3 deletions

View file

@ -1,5 +1,7 @@
package org.bukkit.event.entity;
import java.util.Collections;
import java.util.List;
import org.bukkit.Warning;
import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
@ -17,23 +19,37 @@ public class EntityTransformEvent extends EntityEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
private final Entity converted;
private final List<Entity> convertedList;
private final TransformReason transformReason;
public EntityTransformEvent(Entity original, Entity converted, TransformReason transformReason) {
public EntityTransformEvent(Entity original, List<Entity> convertedList, TransformReason transformReason) {
super(original);
this.converted = converted;
this.convertedList = Collections.unmodifiableList(convertedList);
this.converted = convertedList.get(0);
this.transformReason = transformReason;
}
/**
* Gets the entity that the original entity was transformed to.
*
* This returns the first entity in the transformed entity list.
*
* @return The transformed entity.
* @see #getTransformedEntities()
*/
public Entity getTransformedEntity() {
return converted;
}
/**
* Gets the entities that the original entity was transformed to.
*
* @return The transformed entities.
*/
public List<Entity> getTransformedEntities() {
return convertedList;
}
/**
* Gets the reason for the conversion that has occurred.
*

View file

@ -1,5 +1,7 @@
package org.bukkit.event.entity;
import java.util.Collections;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
@ -16,7 +18,7 @@ public class PigZapEvent extends EntityTransformEvent implements Cancellable {
private final LightningStrike bolt;
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
super(pig, pigzombie, TransformReason.LIGHTNING);
super(pig, Collections.singletonList((Entity) pigzombie), TransformReason.LIGHTNING);
this.bolt = bolt;
this.pigzombie = pigzombie;
}