forked from SpigotMC/Spigot-API
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Define EntitySpawnEvent and SpawnerSpawnEvent
Defines EntitySpawnEvent and SpawnerSpawnEvent. Adds BUKKIT-267 and BUKKIT-1559
- Loading branch information
Showing
4 changed files
with
74 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/org/bukkit/event/entity/EntitySpawnEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.bukkit.event.entity; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.entity.Entity; | ||
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 org.bukkit.event.Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private boolean canceled; | ||
|
||
public EntitySpawnEvent(final Entity spawnee) { | ||
super(spawnee); | ||
} | ||
|
||
public boolean isCancelled() { | ||
return canceled; | ||
} | ||
|
||
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,23 @@ | ||
package org.bukkit.event.entity; | ||
|
||
import org.bukkit.entity.Item; | ||
import org.bukkit.Location; | ||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.HandlerList; | ||
import org.bukkit.entity.Item; | ||
|
||
/** | ||
* Called when an item is spawned into a world | ||
*/ | ||
public class ItemSpawnEvent extends EntityEvent implements Cancellable { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private final Location location; | ||
private boolean canceled; | ||
|
||
public ItemSpawnEvent(final Item spawnee, final Location loc) { | ||
public class ItemSpawnEvent extends EntitySpawnEvent { | ||
public ItemSpawnEvent(final Item spawnee) { | ||
super(spawnee); | ||
this.location = loc; | ||
} | ||
|
||
public boolean isCancelled() { | ||
return canceled; | ||
} | ||
|
||
public void setCancelled(boolean cancel) { | ||
canceled = cancel; | ||
@Deprecated | ||
public ItemSpawnEvent(final Item spawnee, final Location loc) { | ||
this(spawnee); | ||
} | ||
|
||
@Override | ||
public Item getEntity() { | ||
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; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/org/bukkit/event/entity/SpawnerSpawnEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.bukkit.event.entity; | ||
|
||
import org.bukkit.block.CreatureSpawner; | ||
import org.bukkit.entity.Entity; | ||
|
||
/** | ||
* Called when an entity is spawned into a world by a spawner. | ||
* <p> | ||
* If a Spawner Spawn event is cancelled, the entity will not spawn. | ||
*/ | ||
public class SpawnerSpawnEvent extends EntitySpawnEvent { | ||
private final CreatureSpawner spawner; | ||
|
||
public SpawnerSpawnEvent(final Entity spawnee, final CreatureSpawner spawner) { | ||
super(spawnee); | ||
this.spawner = spawner; | ||
} | ||
|
||
public CreatureSpawner getSpawner() { | ||
return spawner; | ||
} | ||
} |