Skip to content

Commit b5976a5

Browse files
committed
Prevent users from setting unsafe homes when teleport safety is disabled.
1 parent 4e6c98a commit b5976a5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Essentials/src/com/earth2me/essentials/commands/Commandsethome.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static com.earth2me.essentials.I18n.tl;
44
import com.earth2me.essentials.User;
5+
import com.earth2me.essentials.utils.LocationUtil;
56
import com.earth2me.essentials.utils.NumberUtil;
67
import java.util.Locale;
78
import org.bukkit.Location;
@@ -44,7 +45,7 @@ public void run(final Server server, final User user, final String commandLabel,
4445
if (usersHome == null)
4546
{
4647
throw new PlayerNotFoundException();
47-
}
48+
}
4849
}
4950
}
5051
}
@@ -56,6 +57,12 @@ public void run(final Server server, final User user, final String commandLabel,
5657
{
5758
throw new NoSuchFieldException(tl("invalidHomeName"));
5859
}
60+
61+
if (!ess.getSettings().isTeleportSafetyEnabled() && LocationUtil.isBlockUnsafeForUser(usersHome, location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ()))
62+
{
63+
throw new Exception(tl("unsafeTeleportDestination", location.getWorld().getName(), location.getBlockX(), location.getBlockY(), location.getBlockZ()));
64+
}
65+
5966
usersHome.setHome(name, location);
6067
user.sendMessage(tl("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ(), name));
6168

0 commit comments

Comments
 (0)