New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[B+C] Add and implement an EntityDespawnEvent. adds BUKKIT-5645 #1070
base: master
Are you sure you want to change the base?
Changes from 5 commits
06c75be
e661a39
0d04471
cd1991b
1adee4a
47521e0
c840e7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package org.bukkit.event.entity; | ||
|
||
import org.bukkit.entity.Entity; | ||
import org.bukkit.event.HandlerList; | ||
|
||
/** | ||
* Called whenever an Entity is removed from the world. | ||
*/ | ||
public class EntityDespawnEvent extends EntityEvent { | ||
private static final HandlerList handlers = new HandlerList(); | ||
private final DespawnReason despawnReason; | ||
|
||
public EntityDespawnEvent(final Entity entity) { | ||
super(entity); | ||
despawnReason = DespawnReason.DEFAULT; | ||
} | ||
|
||
public EntityDespawnEvent(final Entity entity, DespawnReason reason) { | ||
super(entity); | ||
despawnReason = reason; | ||
} | ||
|
||
/** | ||
* Gets the reason for why the creature is being despawned. | ||
* | ||
* @return A DespawnReason value detailing the reason for the entity being despawned | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
public DespawnReason getDespawnReason() { | ||
return despawnReason; | ||
} | ||
|
||
@Override | ||
public HandlerList getHandlers() { | ||
return handlers; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return handlers; | ||
} | ||
|
||
/** | ||
* An enum to specify the type of despawning | ||
*/ | ||
public enum DespawnReason { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enums generally go at the top of the file. |
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra line here |
||
/** | ||
* When an entity despawns due to a chunk unload | ||
*/ | ||
CHUNK_UNLOAD, | ||
/** | ||
* When a living entity despawns because it died | ||
*/ | ||
DEATH, | ||
/** | ||
* When an entity despawns because a plugin or GameRule removed it, | ||
* or a non-living entity died (EG, ender crystal destroyed) | ||
*/ | ||
REMOVED, | ||
/** | ||
* When an entity is missing a DespawnReason | ||
*/ | ||
DEFAULT | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not just fired for creatures - is it?