mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-16 04:21:37 +01:00
Added bed events and methods.
By: sk89q <the.sk89q@gmail.com>
This commit is contained in:
parent
b6e68ee5e5
commit
f31d7de587
@ -45,4 +45,18 @@ public interface HumanEntity extends LivingEntity {
|
|||||||
*
|
*
|
||||||
public void selectItemInHand( int index );
|
public void selectItemInHand( int index );
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this player is slumbering.
|
||||||
|
*
|
||||||
|
* @return slumber state
|
||||||
|
*/
|
||||||
|
public boolean isSleeping();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the sleep ticks of the player. This value may be capped.
|
||||||
|
*
|
||||||
|
* @return slumber ticks
|
||||||
|
*/
|
||||||
|
public int getSleepTicks();
|
||||||
}
|
}
|
||||||
|
@ -270,6 +270,21 @@ public abstract class Event implements Serializable {
|
|||||||
* @see org.bukkit.event.player.PlayerInventoryEvent
|
* @see org.bukkit.event.player.PlayerInventoryEvent
|
||||||
*/
|
*/
|
||||||
PLAYER_INVENTORY(Category.PLAYER),
|
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
|
* BLOCK EVENTS
|
||||||
*/
|
*/
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -172,6 +172,22 @@ public class PlayerListener implements Listener {
|
|||||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
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
|
// TODO: Remove after RB
|
||||||
@Deprecated public void onPlayerQuit(PlayerEvent event) {}
|
@Deprecated public void onPlayerQuit(PlayerEvent event) {}
|
||||||
@Deprecated public void onPlayerCommandPreprocess(PlayerChatEvent event) {}
|
@Deprecated public void onPlayerCommandPreprocess(PlayerChatEvent event) {}
|
||||||
|
@ -312,6 +312,18 @@ public final class JavaPluginLoader implements PluginLoader {
|
|||||||
((PlayerListener) listener).onPlayerBucketFill((PlayerBucketFillEvent) event);
|
((PlayerListener) listener).onPlayerBucketFill((PlayerBucketFillEvent) event);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
case PLAYER_BED_ENTER:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((PlayerListener) listener).onPlayerBedEnter((PlayerBedEnterEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
case PLAYER_BED_LEAVE:
|
||||||
|
return new EventExecutor() {
|
||||||
|
public void execute(Listener listener, Event event) {
|
||||||
|
((PlayerListener) listener).onPlayerBedLeave((PlayerBedLeaveEvent) event);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Block Events
|
// Block Events
|
||||||
case BLOCK_PHYSICS:
|
case BLOCK_PHYSICS:
|
||||||
|
Loading…
Reference in New Issue
Block a user