Reimplement spawn-if-no-home config option (#2757)

This reimplements the `spawn-if-no-home` config option from the original Essentials plugin. If set to true, running `/home` without having set a home will send the player to spawn (previous behaviour). If set to false, running `/home` will instead show an error message and not teleport the player anywhere.

Closes #1452.
This commit is contained in:
Glare 2019-10-20 03:12:53 -05:00 committed by md678685
parent f6a70a542e
commit 882699919e
4 changed files with 15 additions and 1 deletions

View File

@ -337,4 +337,6 @@ public interface ISettings extends IConf {
Set<Predicate<String>> getNickBlacklist();
double getMaxProjectileSpeed();
boolean isSpawnIfNoHome();
}

View File

@ -1624,4 +1624,9 @@ public class Settings implements net.ess3.api.ISettings {
public double getMaxProjectileSpeed() {
return maxProjectileSpeed;
}
@Override
public boolean isSpawnIfNoHome() {
return config.getBoolean("spawn-if-no-home", true);
}
}

View File

@ -53,7 +53,11 @@ public class Commandhome extends EssentialsCommand {
Location bed = player.getBase().getBedSpawnLocation();
final List<String> homes = player.getHomes();
if (homes.isEmpty() && player.equals(user)) {
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
if (ess.getSettings().isSpawnIfNoHome()) {
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
} else {
throw new Exception(tl("noHomeSetPlayer"));
}
} else if (homes.isEmpty()) {
throw new Exception(tl("noHomeSetPlayer"));
} else if (homes.size() == 1 && player.equals(user)) {

View File

@ -920,6 +920,9 @@ spawn-join-listener-priority: high
# When users die, should they respawn at their first home or bed, instead of the spawnpoint?
respawn-at-home: false
# If no home is set, would you like to send the player to spawn? (Only applies to /home)
spawn-if-no-home: true
# Teleport all joining players to the spawnpoint
spawn-on-join: false
# The following value of `guests` states that all players in group `guests` will be teleported to spawn when joining.