diff --git a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java index e6b5043e079..25bf82f6a25 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java +++ b/Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java @@ -795,12 +795,15 @@ public void onPlayerInteract(final PlayerInteractEvent event) { break; } final User player = ess.getUser(event.getPlayer()); - if (player.isAuthorized("essentials.sethome.bed") && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { + final boolean isAuthorized = player.isAuthorized("essentials.sethome.bed"); + if (isAuthorized && player.getWorld().getEnvironment().equals(World.Environment.NORMAL)) { player.getBase().setBedSpawnLocation(event.getClickedBlock().getLocation()); // In 1.15 and above, vanilla sends its own bed spawn message. if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_15_R01)) { player.sendTl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()); } + } else if (!isAuthorized) { + event.setCancelled(true); } } break; diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java index a8017dcbf8a..8040366bc3a 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java @@ -74,9 +74,13 @@ public void run(final Server server, final User user, final String commandLabel, if (homes.isEmpty() && finalPlayer.equals(user)) { if (ess.getSettings().isSpawnIfNoHome()) { final UserTeleportHomeEvent event = new UserTeleportHomeEvent(user, null, bed != null ? bed : finalPlayer.getWorld().getSpawnLocation(), bed != null ? UserTeleportHomeEvent.HomeType.BED : UserTeleportHomeEvent.HomeType.SPAWN); - server.getPluginManager().callEvent(event); - if (!event.isCancelled()) { - user.getAsyncTeleport().respawn(charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel)); + if (event.getHomeType() != UserTeleportHomeEvent.HomeType.BED || finalPlayer.isAuthorized("essentials.home.bed")) { + server.getPluginManager().callEvent(event); + if (!event.isCancelled()) { + user.getAsyncTeleport().respawn(charge, TeleportCause.COMMAND, getNewExceptionFuture(user.getSource(), commandLabel)); + } + } else { + showError(user.getBase(), new TranslatableException("noPerm", "essentials.home.bed"), commandLabel); } } else { showError(user.getBase(), new TranslatableException("noHomeSetPlayer"), commandLabel);