From 5ce1075ec0c6d41d66ecbe14250763573297590f Mon Sep 17 00:00:00 2001 From: Font Vincent Date: Wed, 11 Dec 2024 17:12:22 +0100 Subject: [PATCH] fix: essentials.home.bed permission --- .../earth2me/essentials/commands/Commandhome.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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..1c93cd17918 100644 --- a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java @@ -73,10 +73,14 @@ public void run(final Server server, final User user, final String commandLabel, final List homes = finalPlayer.getHomes(); 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(bed == null || finalPlayer.isAuthorized("essentials.home.bed")){ + 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)); + } + }else { + showError(user.getBase(), new TranslatableException("noPerm", "essentials.home.bed"), commandLabel); } } else { showError(user.getBase(), new TranslatableException("noHomeSetPlayer"), commandLabel);