mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
API to prevent PlayerBedLeaveEvent from changing a player's spawn location
By: Senmori <thesenmori@gmail.com>
This commit is contained in:
parent
a5e572dd9e
commit
30d8b71004
1 changed files with 36 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package org.bukkit.event.player;
|
package org.bukkit.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
@ -10,10 +11,12 @@ import org.bukkit.event.HandlerList;
|
||||||
public class PlayerBedLeaveEvent extends PlayerEvent {
|
public class PlayerBedLeaveEvent extends PlayerEvent {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private final Block bed;
|
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);
|
super(who);
|
||||||
this.bed = bed;
|
this.bed = bed;
|
||||||
|
this.setBedSpawn = setBedSpawn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +28,38 @@ public class PlayerBedLeaveEvent extends PlayerEvent {
|
||||||
return bed;
|
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
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|
Loading…
Reference in a new issue