use of org.bukkit.event.player.PlayerBedEnterEvent in project Glowstone by GlowstoneMC.
the class GlowPlayer method enterBed.
/**
* This player enters the specified bed and is marked as sleeping.
*
* @param block the bed
*/
public void enterBed(GlowBlock block) {
checkNotNull(block, "Bed block cannot be null");
Preconditions.checkState(bed == null, "Player already in bed");
GlowBlock head = BlockBed.getHead(block);
GlowBlock foot = BlockBed.getFoot(block);
if (EventFactory.getInstance().callEvent(new PlayerBedEnterEvent(this, head)).isCancelled()) {
return;
}
// Occupy the bed
BlockBed.setOccupied(head, foot, true);
bed = head;
sleeping = true;
setRawLocation(head.getLocation(), false);
// TODO: Set bed metadata (LivingEntity)
}
Aggregations