Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3fe1495

Browse files
Hunh0wJRoy
andauthoredMay 25, 2025··
Fix unexpected behavior with essentials.home.bed & essentials.sethome.bed permissions (#5991)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
1 parent 3b0c229 commit 3fe1495

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
 

‎Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,15 @@ public void onPlayerInteract(final PlayerInteractEvent event) {
823823
break;
824824
}
825825
final User player = ess.getUser(event.getPlayer());
826-
if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
826+
final boolean isAuthorized = player.isAuthorized("essentials.sethome.bed");
827+
if (isAuthorized && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) {
827828
player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation());
828829
// In 1.15 and above, vanilla sends its own bed spawn message.
829830
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_R01)) {
830831
player.sendTl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
831832
}
833+
} else if (!isAuthorized) {
834+
event.setCancelled(true);
832835
}
833836
}
834837
break;

‎Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,13 @@ public void run(final Server server, final User user, final String commandLabel,
7474
if (homes.isEmpty() && finalPlayer.equals(user)) {
7575
if (ess.getSettings().isSpawnIfNoHome()) {
7676
final UserTeleportHomeEvent event = new UserTeleportHomeEvent(user, null, bed != null ? bed : finalPlayer.getWorld().getSpawnLocation(), bed != null ? UserTeleportHomeEvent.HomeType.BED : UserTeleportHomeEvent.HomeType.SPAWN);
77-
server.getPluginManager().callEvent(event);
78-
if (!event.isCancelled()) {
79-
user.getAsyncTeleport().respawn(charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
77+
if (event.getHomeType() != UserTeleportHomeEvent.HomeType.BED || finalPlayer.isAuthorized("essentials.home.bed")) {
78+
server.getPluginManager().callEvent(event);
79+
if (!event.isCancelled()) {
80+
user.getAsyncTeleport().respawn(charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel));
81+
}
82+
} else {
83+
showError(user.getBase(), new TranslatableException("noPerm", "essentials.home.bed"), commandLabel);
8084
}
8185
} else {
8286
showError(user.getBase(), new TranslatableException("noHomeSetPlayer"), commandLabel);

0 commit comments

Comments
 (0)
Please sign in to comment.