001    package org.bukkit.event.player;
002    
003    import org.apache.commons.lang.Validate;
004    import org.bukkit.Location;
005    import org.bukkit.entity.Player;
006    import org.bukkit.event.HandlerList;
007    
008    /**
009     * Called when a player respawns.
010     */
011    public class PlayerRespawnEvent extends PlayerEvent {
012        private static final HandlerList handlers = new HandlerList();
013        private Location respawnLocation;
014        private final boolean isBedSpawn;
015    
016        public PlayerRespawnEvent(final Player respawnPlayer, final Location respawnLocation, final boolean isBedSpawn) {
017            super(respawnPlayer);
018            this.respawnLocation = respawnLocation;
019            this.isBedSpawn = isBedSpawn;
020        }
021    
022        /**
023         * Gets the current respawn location
024         *
025         * @return Location current respawn location
026         */
027        public Location getRespawnLocation() {
028            return this.respawnLocation;
029        }
030    
031        /**
032         * Sets the new respawn location
033         *
034         * @param respawnLocation new location for the respawn
035         */
036        public void setRespawnLocation(Location respawnLocation) {
037            Validate.notNull(respawnLocation, "Respawn location can not be null");
038            Validate.notNull(respawnLocation.getWorld(), "Respawn world can not be null");
039    
040            this.respawnLocation = respawnLocation;
041        }
042    
043        /**
044         * Gets whether the respawn location is the player's bed.
045         *
046         * @return true if the respawn location is the player's bed.
047         */
048        public boolean isBedSpawn() {
049            return this.isBedSpawn;
050        }
051    
052        @Override
053        public HandlerList getHandlers() {
054            return handlers;
055        }
056    
057        public static HandlerList getHandlerList() {
058            return handlers;
059        }
060    }