mirror of
https://github.com/EssentialsX/Essentials.git
synced 2026-11-05 09:10:17 -05:00
Fix unexpected behavior with essentials.home.bed & essentials.sethome.bed permissions (#5991)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
1 parent
3b0c229e78
commit
3fe1495fdb
2 files changed
+11
-4
No files matched your search
@@ -823,12 +823,15 @@ public class EssentialsPlayerListener implements Listener, FakeAccessor {
|
||||
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;
|
||||
|
||||
@@ -74,9 +74,13 @@ public class Commandhome extends EssentialsCommand {
|
||||
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);
|
||||
|
||||
Reference in new issue
Block a user