Added bed events and methods.

By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
Bukkit/Spigot
2011-04-07 11:26:33 -07:00
parent b6e68ee5e5
commit f31d7de587
6 changed files with 136 additions and 0 deletions

View File

@@ -270,6 +270,21 @@ public abstract class Event implements Serializable {
* @see org.bukkit.event.player.PlayerInventoryEvent
*/
PLAYER_INVENTORY(Category.PLAYER),
/**
* Called when a player enter a bed
*
* @see org.bukkit.event.player.PlayerBedEnterEvent
*/
PLAYER_BED_ENTER(Category.PLAYER),
/**
* Called when a player leaves a bed
*
* @see org.bukkit.event.player.PlayerBedEnterEvent
*/
PLAYER_BED_LEAVE(Category.PLAYER),
/**
* BLOCK EVENTS
*/

View File

@@ -0,0 +1,50 @@
package org.bukkit.event.player;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
/**
* This event is fired when the player is almost about to enter the bed.
* It can be cancelled.
*
* @author sk89q
*/
public class PlayerBedEnterEvent extends PlayerEvent implements Cancellable {
private boolean cancel = false;
private Block bed;
public PlayerBedEnterEvent(Player who, Block bed) {
super(Type.PLAYER_BED_ENTER, who);
this.bed = bed;
}
/**
* Gets the cancellation state of this event.
*
* @return true if this event is cancelled
*/
public boolean isCancelled() {
return cancel;
}
/**
* Prevents the player from entering the bed.
*
* @param cancel true if you wish to cancel this event
*/
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
/**
* Returns the bed block.
*
* @return
*/
public Block getBed() {
return bed;
}
}

View File

@@ -0,0 +1,29 @@
package org.bukkit.event.player;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
/**
* This event is fired when the player is leaving a bed.
*
* @author sk89q
*/
public class PlayerBedLeaveEvent extends PlayerEvent {
private Block bed;
public PlayerBedLeaveEvent(Player who, Block bed) {
super(Type.PLAYER_BED_LEAVE, who);
this.bed = bed;
}
/**
* Returns the bed block.
*
* @return
*/
public Block getBed() {
return bed;
}
}

View File

@@ -172,6 +172,22 @@ public class PlayerListener implements Listener {
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
}
/**
* Called when a player enters a bed
*
* @param event Relevant event details
*/
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
}
/**
* Called when a player leaves a bed
*
* @param event Relevant event details
*/
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
}
// TODO: Remove after RB
@Deprecated public void onPlayerQuit(PlayerEvent event) {}
@Deprecated public void onPlayerCommandPreprocess(PlayerChatEvent event) {}