diff options
author | Senmori <thesenmori@gmail.com> | 2018-08-27 02:47:18 -0400 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-08-29 19:08:30 +1000 |
commit | 9ca2772d4f0b92029844ee0a1bf69ba1d6e73366 (patch) | |
tree | 229792717c39f95ec17fa6a174d4a2a74058b1be /src | |
parent | 0279d9b41516e1fa566848cc5affdd0fca0028de (diff) | |
download | bukkit-9ca2772d4f0b92029844ee0a1bf69ba1d6e73366.tar bukkit-9ca2772d4f0b92029844ee0a1bf69ba1d6e73366.tar.gz bukkit-9ca2772d4f0b92029844ee0a1bf69ba1d6e73366.tar.lz bukkit-9ca2772d4f0b92029844ee0a1bf69ba1d6e73366.tar.xz bukkit-9ca2772d4f0b92029844ee0a1bf69ba1d6e73366.zip |
API to prevent PlayerBedLeaveEvent from changing a player's spawn location
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java index 628ab0b0..0b57635f 100644 --- a/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerBedLeaveEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.player; +import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; @@ -10,10 +11,12 @@ import org.bukkit.event.HandlerList; public class PlayerBedLeaveEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); private final Block bed; + private boolean setBedSpawn; - public PlayerBedLeaveEvent(final Player who, final Block bed) { + public PlayerBedLeaveEvent(final Player who, final Block bed, boolean setBedSpawn) { super(who); this.bed = bed; + this.setBedSpawn = setBedSpawn; } /** @@ -25,6 +28,38 @@ public class PlayerBedLeaveEvent extends PlayerEvent { return bed; } + /** + * Get if this event should set the new spawn location for the + * {@link Player}. + * <br> + * This does not remove any existing spawn location, only prevent it from + * being changed (if true). + * <br> + * To change a {@link Player}'s spawn location, use + * {@link Player#setBedSpawnLocation(Location)}. + * + * @return true if the spawn location will be changed + */ + public boolean shouldSetSpawnLocation() { + return setBedSpawn; + } + + /** + * Set if this event should set the new spawn location for the + * {@link Player}. + * <br> + * This will not remove any existing spawn location, only prevent it from + * being changed (if true). + * <br> + * To change a {@link Player}'s spawn location, use + * {@link Player#setBedSpawnLocation(Location)}. + * + * @param setBedSpawn true to change the new spawn location + */ + public void setSpawnLocation(boolean setBedSpawn) { + this.setBedSpawn = setBedSpawn; + } + @Override public HandlerList getHandlers() { return handlers; |