fix: essentials.home.bed & essentials.sethome.bed permissions#5991
fix: essentials.home.bed & essentials.sethome.bed permissions#5991JRoy merged 5 commits intoEssentialsX:2.xfrom
Conversation
pop4959
left a comment
There was a problem hiding this comment.
Hey, thanks for making your first PR to Essentials! We appreciate it.
I left a few comments for you to look at. Please also share proof of testing (show before/after screenshot is probably the easiest) in the demonstration section which you left blank.
Also, in the original issue, essentials.sethome.bed is mentioned. Have you checked if there is a problem with /sethome or is this working as intended?
Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java
Outdated
Show resolved
Hide resolved
Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull Request Overview
This PR ensures players need the correct permissions for bed-related home commands, preventing misleading errors and unauthorized actions.
- Adds a permission check for
/home bedto show a no-permission message instead of a generic no-home error. - Cancels bed spawn setting in the world when a player lacks the
essentials.sethome.bedpermission.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java | Wrapped the teleport event and spawn logic in a bed-permission check and shows a no-perm error. |
| Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java | Introduced an isAuthorized flag and cancels bed-click interactions when permission is missing. |
Comments suppressed due to low confidence (2)
Essentials/src/main/java/com/earth2me/essentials/commands/Commandhome.java:76
- [nitpick] Consider moving the permission check before creating the UserTeleportHomeEvent to avoid instantiating and scheduling events for users who aren’t authorized.
final UserTeleportHomeEvent event = new UserTeleportHomeEvent(user, null, bed != null ? bed : finalPlayer.getWorld().getSpawnLocation(), bed != null ? UserTeleportHomeEvent.HomeType.BED : UserTeleportHomeEvent.HomeType.SPAWN);
Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java:826
- [nitpick] The variable name
isAuthorizedis generic; consider renaming tohasSethomeBedPermissionfor clarity about which permission is being checked.
final boolean isAuthorized = player.isAuthorized("essentials.sethome.bed");
Essentials/src/main/java/com/earth2me/essentials/EssentialsPlayerListener.java
Show resolved
Hide resolved
|
thanks! |
|
Since this commit I can't sleep at night and can't set respawn point. Previous build (2.21.1-dev+18-3b0c229) was fine. |
| player.sendTl("bedSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()); | ||
| } | ||
| } else if (!isAuthorized) { | ||
| event.setCancelled(true); |
There was a problem hiding this comment.
This prevents people interacting with the bed. Why was this changed?
There was a problem hiding this comment.
This was because if someone interact with a bed, they automatically set the bed home even if they don't have the permission
EssentialsX@40540eb Expose IUser#getLastActivityTime to API (EssentialsX#6101) EssentialsX@50b696b Adds social spy message type for in EssentialsDiscord (EssentialsX#5620) EssentialsX@dabe687 Add SignTransactionEvent for buy and sell signs (EssentialsX#6071) EssentialsX@0cb387f Fix NPE when unlinking offline players (EssentialsX#6111) EssentialsX@f09541c Update to Minecraft 1.21.5 (EssentialsX#6109) EssentialsX@c7ff994 Fire GlobalChatEvent even when local chat is disabled (EssentialsX#6113) EssentialsX@06c886c Fix /baltop on 1.15.2 and below (EssentialsX#6115) EssentialsX@2bb4438 Fix further trade sign validation mismatches (EssentialsX#6116) EssentialsX@8455212 Fix /spawnmob on < 1.21.5 (EssentialsX#6121) EssentialsX@be3e641 New Crowdin updates (EssentialsX#6089) EssentialsX@3f5b122 Use legacy text for TranslatableException#getMessage (EssentialsX#6134) EssentialsX@fe43017 Fix heer typo in messages_en.properties (EssentialsX#6135) EssentialsX@a58db23 Update English source strings with fixes from Crowdin (EssentialsX#6140) EssentialsX@d137031 Improve config comments & ordering (EssentialsX#6108) EssentialsX@3b0c229 New Crowdin updates (EssentialsX#6131) EssentialsX@3fe1495 Fix unexpected behavior with essentials.home.bed & essentials.sethome.bed permissions (EssentialsX#5991) EssentialsX@aebe851 Fix double messages when deleting a non-existent home (EssentialsX#6150) EssentialsX@3a5c7c4 Revert changes to /home and /sethome that break bed interactions (EssentialsX#6151) EssentialsX@3d28d82 Release 2.21.1 EssentialsX@e836747 Prepare for 2.21.2 dev builds (EssentialsX#6128) EssentialsX@d42347f Fix sending message during /editsign paste if SignChangeEvent is cancelled (EssentialsX#6136) EssentialsX@997f600 Update adventure dependencies (EssentialsX#6163) EssentialsX@4057326 Update to Minecraft 1.21.6 EssentialsX@2796399 Add 1.21.6 Mobs EssentialsX@31ea903 Move tests to MockBukkit EssentialsX@ff1b8b8 Add 1.21.6 Aliases




Information
This PR fixes #5963.
Details
Proposed fix:
If the player uses "/home bed" when he doesn't have the "essentials.home.bed" permission, he's getting a no permission error for it
Environments tested:
OS: Ubuntu 24.04.1 LTS
Java version: 21
Demonstration: