diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 5453f5265..96c1e24cd 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -121,6 +121,8 @@ public interface ISettings extends IConf { boolean isForceDisableTeleportSafety(); + boolean isAlwaysTeleportSafety(); + boolean isTeleportPassengerDismount(); double getTeleportCooldown(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index d8dbbe89a..6046fc3e4 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -157,6 +157,11 @@ public class Settings implements net.ess3.api.ISettings { return forceDisableTeleportSafety; } + @Override + public boolean isAlwaysTeleportSafety() { + return config.getBoolean("force-safe-teleport-location", false); + } + @Override public boolean isTeleportPassengerDismount() { return config.getBoolean("teleport-passenger-dismount", true); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java index 32e6fa185..0ac4f2ec2 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.commands; +import com.earth2me.essentials.OfflinePlayer; import com.earth2me.essentials.Trade; import com.earth2me.essentials.User; import com.earth2me.essentials.utils.StringUtil; @@ -41,7 +42,7 @@ public class Commandhome extends EssentialsCommand { } try { if ("bed".equalsIgnoreCase(homeName) && user.isAuthorized("essentials.home.bed")) { - if (!player.getBase().isOnline()) { + if (!player.getBase().isOnline() || player.getBase() instanceof OfflinePlayer) { throw new Exception(tl("bedOffline")); } PaperLib.getBedSpawnLocationAsync(player.getBase(), true).thenAccept(location -> { diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java index 5a81b2c69..307b0ea65 100644 --- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java @@ -153,8 +153,8 @@ public class LocationUtil { } public static Location getSafeDestination(final IEssentials ess, final IUser user, final Location loc) throws Exception { - if (user.getBase().isOnline() && (user.getBase().getGameMode() == GameMode.CREATIVE || user.getBase().getGameMode() == GameMode.SPECTATOR || user.isGodModeEnabled()) || user.getBase().getAllowFlight()) { - if (shouldFly(loc)) { + if (user.getBase().isOnline() && (ess == null || !ess.getSettings().isAlwaysTeleportSafety()) && (user.getBase().getGameMode() == GameMode.CREATIVE || user.getBase().getGameMode() == GameMode.SPECTATOR || user.isGodModeEnabled())) { + if (shouldFly(loc) && user.getBase().getAllowFlight()) { user.getBase().setFlying(true); } // ess can be null if old deprecated method is calling it. diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 7f8e194c4..3cca03c2a 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -78,6 +78,10 @@ teleport-safety: true # teleport-safety and this option need to be set to true to force teleportation to dangerous locations. force-disable-teleport-safety: false +# If a player is teleporting to an unsafe location in creative, adventure, or god mode; they will not be teleported to a +# safe location. If you'd like players to be teleported to a safe location all of the time, set this option to true. +force-safe-teleport-location: false + # If a player has any passengers, the teleport will fail. Should their passengers be dismounted before they are teleported? # If this is set to true, Essentials will dismount the player's passengers before teleporting. # If this is set to false, attempted teleports will be canceled with a warning.