geforkt von Mirrors/Paper
Narrowed down the return type of most EntityEvent subclasses for convenience. Addresses BUKKIT-809
By: TomyLobo <tomylobo@nurfuerspam.de>
Dieser Commit ist enthalten in:
Ursprung
345f24b35c
Commit
38fd1dd5f0
@ -1,8 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@ -37,6 +36,11 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
||||
canceled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location at which the creature is spawning.
|
||||
*
|
||||
@ -54,16 +58,7 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
||||
*/
|
||||
@Deprecated
|
||||
public CreatureType getCreatureType() {
|
||||
return CreatureType.fromEntityType(getSpawnedType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of creature being spawned.
|
||||
*
|
||||
* @return A CreatureType value detailing the type of creature being spawned
|
||||
*/
|
||||
public EntityType getSpawnedType() {
|
||||
return getEntity().getType();
|
||||
return CreatureType.fromEntityType(getEntityType());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -13,14 +14,14 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean canceled;
|
||||
private final PowerCause cause;
|
||||
private Entity bolt;
|
||||
private LightningStrike bolt;
|
||||
|
||||
public CreeperPowerEvent(final Entity creeper, final Entity bolt, final PowerCause cause) {
|
||||
public CreeperPowerEvent(final Creeper creeper, final LightningStrike bolt, final PowerCause cause) {
|
||||
this(creeper, cause);
|
||||
this.bolt = bolt;
|
||||
}
|
||||
|
||||
public CreeperPowerEvent(final Entity creeper, final PowerCause cause) {
|
||||
public CreeperPowerEvent(final Creeper creeper, final PowerCause cause) {
|
||||
super(creeper);
|
||||
this.cause = cause;
|
||||
}
|
||||
@ -33,12 +34,17 @@ public class CreeperPowerEvent extends EntityEvent implements Cancellable {
|
||||
canceled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Creeper getEntity() {
|
||||
return (Creeper) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the lightning bolt which is striking the Creeper.
|
||||
*
|
||||
* @return The Entity for the lightning bolt which is striking the Creeper
|
||||
*/
|
||||
public Entity getLightning() {
|
||||
public LightningStrike getLightning() {
|
||||
return bolt;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -17,13 +17,18 @@ public class EntityChangeBlockEvent extends EntityEvent implements Cancellable {
|
||||
private boolean cancel;
|
||||
private final Material to;
|
||||
|
||||
public EntityChangeBlockEvent(final Entity what, final Block block, final Material to) {
|
||||
public EntityChangeBlockEvent(final LivingEntity what, final Block block, final Material to) {
|
||||
super(what);
|
||||
this.block = block;
|
||||
this.cancel = false;
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the block the entity is changing
|
||||
*
|
||||
|
@ -3,7 +3,7 @@ package org.bukkit.event.entity;
|
||||
import java.util.List;
|
||||
import org.bukkit.PortalType;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -16,13 +16,18 @@ public class EntityCreatePortalEvent extends EntityEvent implements Cancellable
|
||||
private boolean cancelled = false;
|
||||
private PortalType type = PortalType.CUSTOM;
|
||||
|
||||
public EntityCreatePortalEvent(final Entity what, final List<BlockState> blocks, final PortalType type) {
|
||||
public EntityCreatePortalEvent(final LivingEntity what, final List<BlockState> blocks, final PortalType type) {
|
||||
super(what);
|
||||
|
||||
this.blocks = blocks;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of all blocks associated with the portal.
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@ -13,16 +13,21 @@ public class EntityDeathEvent extends EntityEvent {
|
||||
private final List<ItemStack> drops;
|
||||
private int dropExp = 0;
|
||||
|
||||
public EntityDeathEvent(final Entity entity, final List<ItemStack> drops) {
|
||||
public EntityDeathEvent(final LivingEntity entity, final List<ItemStack> drops) {
|
||||
this(entity, drops, 0);
|
||||
}
|
||||
|
||||
public EntityDeathEvent(final Entity what, final List<ItemStack> drops, final int droppedExp) {
|
||||
public EntityDeathEvent(final LivingEntity what, final List<ItemStack> drops, final int droppedExp) {
|
||||
super(what);
|
||||
this.drops = drops;
|
||||
this.dropExp = droppedExp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets how much EXP should be dropped from this death.
|
||||
* <p>
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.Event;
|
||||
|
||||
/**
|
||||
@ -18,7 +19,16 @@ public abstract class EntityEvent extends Event {
|
||||
*
|
||||
* @return Entity who is involved in this event
|
||||
*/
|
||||
public final Entity getEntity() {
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the EntityType of the Entity involved in this event.
|
||||
*
|
||||
* @return EntityType of the Entity involved in this event
|
||||
*/
|
||||
public EntityType getEntityType() {
|
||||
return entity.getType();
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,11 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
|
||||
this.force = force;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bow ItemStack used to fire the arrow; is null if the shooter is a skeleton
|
||||
*
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -13,11 +13,16 @@ public class EntityTameEvent extends EntityEvent implements Cancellable {
|
||||
private boolean cancelled;
|
||||
private final AnimalTamer owner;
|
||||
|
||||
public EntityTameEvent(final Entity entity, final AnimalTamer owner) {
|
||||
public EntityTameEvent(final LivingEntity entity, final AnimalTamer owner) {
|
||||
super(entity);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LivingEntity getEntity() {
|
||||
return (LivingEntity) entity;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -12,14 +12,19 @@ public class FoodLevelChangeEvent extends EntityEvent implements Cancellable {
|
||||
private boolean cancel = false;
|
||||
private int level;
|
||||
|
||||
public FoodLevelChangeEvent(final Entity what, final int level) {
|
||||
public FoodLevelChangeEvent(final HumanEntity what, final int level) {
|
||||
super(what);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HumanEntity getEntity() {
|
||||
return (HumanEntity) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the resultant food level that the entity involved in this event should be set to.
|
||||
* <br /><br />
|
||||
* <p />
|
||||
* Where 20 is a full food bar and 0 is an empty one.
|
||||
*
|
||||
* @return The resultant food level
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -10,8 +10,8 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
|
||||
private boolean canceled;
|
||||
private final Location location;
|
||||
|
||||
public ItemDespawnEvent(final Entity spawnee, final Location loc) {
|
||||
super(spawnee);
|
||||
public ItemDespawnEvent(final Item despawnee, final Location loc) {
|
||||
super(despawnee);
|
||||
location = loc;
|
||||
}
|
||||
|
||||
@ -23,6 +23,11 @@ public class ItemDespawnEvent extends EntityEvent implements Cancellable {
|
||||
canceled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getEntity() {
|
||||
return (Item) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location at which the item is despawning.
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -13,7 +13,7 @@ public class ItemSpawnEvent extends EntityEvent implements Cancellable {
|
||||
private final Location location;
|
||||
private boolean canceled;
|
||||
|
||||
public ItemSpawnEvent(final Entity spawnee, final Location loc) {
|
||||
public ItemSpawnEvent(final Item spawnee, final Location loc) {
|
||||
super(spawnee);
|
||||
this.location = loc;
|
||||
}
|
||||
@ -26,6 +26,11 @@ public class ItemSpawnEvent extends EntityEvent implements Cancellable {
|
||||
canceled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Item getEntity() {
|
||||
return (Item) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location at which the item is spawning.
|
||||
*
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.Pig;
|
||||
import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -10,10 +12,10 @@ import org.bukkit.event.HandlerList;
|
||||
public class PigZapEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean canceled;
|
||||
private final Entity pigzombie;
|
||||
private final Entity bolt;
|
||||
private final PigZombie pigzombie;
|
||||
private final LightningStrike bolt;
|
||||
|
||||
public PigZapEvent(final Entity pig, final Entity bolt, final Entity pigzombie) {
|
||||
public PigZapEvent(final Pig pig, final LightningStrike bolt, final PigZombie pigzombie) {
|
||||
super(pig);
|
||||
this.bolt = bolt;
|
||||
this.pigzombie = pigzombie;
|
||||
@ -27,12 +29,17 @@ public class PigZapEvent extends EntityEvent implements Cancellable {
|
||||
canceled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pig getEntity() {
|
||||
return (Pig) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bolt which is striking the pig.
|
||||
*
|
||||
* @return lightning entity
|
||||
*/
|
||||
public Entity getLightning() {
|
||||
public LightningStrike getLightning() {
|
||||
return bolt;
|
||||
}
|
||||
|
||||
@ -42,7 +49,7 @@ public class PigZapEvent extends EntityEvent implements Cancellable {
|
||||
*
|
||||
* @return resulting entity
|
||||
*/
|
||||
public Entity getPigZombie() {
|
||||
public PigZombie getPigZombie() {
|
||||
return pigzombie;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,11 @@ public class PlayerDeathEvent extends EntityDeathEvent {
|
||||
this.deathMessage = deathMessage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getEntity() {
|
||||
return (Player) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the death message that will appear to everyone on the server.
|
||||
*
|
||||
|
@ -24,6 +24,11 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
|
||||
this.affectedEntities = affectedEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThrownPotion getEntity() {
|
||||
return (ThrownPotion) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the potion which caused this event
|
||||
*
|
||||
|
@ -13,6 +13,11 @@ public class ProjectileHitEvent extends EntityEvent {
|
||||
super(projectile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Projectile getEntity() {
|
||||
return (Projectile) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -13,8 +13,8 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
|
||||
private boolean cancel;
|
||||
private DyeColor color;
|
||||
|
||||
public SheepDyeWoolEvent(final Entity what, final DyeColor color) {
|
||||
super(what);
|
||||
public SheepDyeWoolEvent(final Sheep sheep, final DyeColor color) {
|
||||
super(sheep);
|
||||
this.cancel = false;
|
||||
this.color = color;
|
||||
}
|
||||
@ -27,6 +27,11 @@ public class SheepDyeWoolEvent extends EntityEvent implements Cancellable {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheep getEntity() {
|
||||
return (Sheep) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the DyeColor the sheep is being dyed
|
||||
*
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -11,8 +11,8 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel;
|
||||
|
||||
public SheepRegrowWoolEvent(final Entity what) {
|
||||
super(what);
|
||||
public SheepRegrowWoolEvent(final Sheep sheep) {
|
||||
super(sheep);
|
||||
this.cancel = false;
|
||||
}
|
||||
|
||||
@ -24,6 +24,11 @@ public class SheepRegrowWoolEvent extends EntityEvent implements Cancellable {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheep getEntity() {
|
||||
return (Sheep) entity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.bukkit.event.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
@ -9,12 +9,11 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class SlimeSplitEvent extends EntityEvent implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancel;
|
||||
private boolean cancel = false;
|
||||
private int count;
|
||||
|
||||
public SlimeSplitEvent(final Entity what, final int count) {
|
||||
super(what);
|
||||
this.cancel = false;
|
||||
public SlimeSplitEvent(final Slime slime, final int count) {
|
||||
super(slime);
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
@ -26,6 +25,11 @@ public class SlimeSplitEvent extends EntityEvent implements Cancellable {
|
||||
this.cancel = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Slime getEntity() {
|
||||
return (Slime) entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of smaller slimes to spawn
|
||||
*
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren