mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 19:34:09 +01:00
Define EntitySpawnEvent
By: Andy Shulman <andy.shulman@hotmail.com>
This commit is contained in:
parent
c4d30af0eb
commit
21b8238e91
3 changed files with 57 additions and 65 deletions
|
@ -2,17 +2,13 @@ package org.bukkit.event.entity;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a creature is spawned into a world.
|
* Called when a creature is spawned into a world.
|
||||||
* <p>
|
* <p>
|
||||||
* If a Creature Spawn event is cancelled, the creature will not spawn.
|
* If a Creature Spawn event is cancelled, the creature will not spawn.
|
||||||
*/
|
*/
|
||||||
public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
public class CreatureSpawnEvent extends EntitySpawnEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private boolean canceled;
|
|
||||||
private final SpawnReason spawnReason;
|
private final SpawnReason spawnReason;
|
||||||
|
|
||||||
public CreatureSpawnEvent(final LivingEntity spawnee, final SpawnReason spawnReason) {
|
public CreatureSpawnEvent(final LivingEntity spawnee, final SpawnReason spawnReason) {
|
||||||
|
@ -20,28 +16,11 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
||||||
this.spawnReason = spawnReason;
|
this.spawnReason = spawnReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return canceled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
canceled = cancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LivingEntity getEntity() {
|
public LivingEntity getEntity() {
|
||||||
return (LivingEntity) entity;
|
return (LivingEntity) entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the location at which the creature is spawning.
|
|
||||||
*
|
|
||||||
* @return The location at which the creature is spawning
|
|
||||||
*/
|
|
||||||
public Location getLocation() {
|
|
||||||
return getEntity().getLocation();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the reason for why the creature is being spawned.
|
* Gets the reason for why the creature is being spawned.
|
||||||
*
|
*
|
||||||
|
@ -52,15 +31,6 @@ public class CreatureSpawnEvent extends EntityEvent implements Cancellable {
|
||||||
return spawnReason;
|
return spawnReason;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enum to specify the type of spawning
|
* An enum to specify the type of spawning
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when an entity is spawned into a world.
|
||||||
|
* <p>
|
||||||
|
* If an Entity Spawn event is cancelled, the entity will not spawn.
|
||||||
|
*/
|
||||||
|
public class EntitySpawnEvent extends EntityEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean canceled;
|
||||||
|
|
||||||
|
public EntitySpawnEvent(final Entity spawnee) {
|
||||||
|
super(spawnee);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return canceled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
canceled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location at which the entity is spawning.
|
||||||
|
*
|
||||||
|
* @return The location at which the entity is spawning
|
||||||
|
*/
|
||||||
|
public Location getLocation() {
|
||||||
|
return getEntity().getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,51 +1,24 @@
|
||||||
package org.bukkit.event.entity;
|
package org.bukkit.event.entity;
|
||||||
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when an item is spawned into a world
|
* Called when an item is spawned into a world
|
||||||
*/
|
*/
|
||||||
public class ItemSpawnEvent extends EntityEvent implements Cancellable {
|
public class ItemSpawnEvent extends EntitySpawnEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
|
||||||
private final Location location;
|
|
||||||
private boolean canceled;
|
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public ItemSpawnEvent(final Item spawnee, final Location loc) {
|
public ItemSpawnEvent(final Item spawnee, final Location loc) {
|
||||||
|
this(spawnee);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemSpawnEvent(final Item spawnee) {
|
||||||
super(spawnee);
|
super(spawnee);
|
||||||
this.location = loc;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return canceled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
canceled = cancel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Item getEntity() {
|
public Item getEntity() {
|
||||||
return (Item) entity;
|
return (Item) entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the location at which the item is spawning.
|
|
||||||
*
|
|
||||||
* @return The location at which the item is spawning
|
|
||||||
*/
|
|
||||||
public Location getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HandlerList getHandlers() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
|
||||||
return handlers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue