Skip to content

Commit

Permalink
Reimplement spawn-if-no-home config option (#2757)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
darbyjack authored and mdcfe committed Oct 20, 2019
1 parent f6a70a5 commit 8826999
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Essentials/src/com/earth2me/essentials/ISettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -337,4 +337,6 @@ public interface ISettings extends IConf {
Set<Predicate<String>> getNickBlacklist();

double getMaxProjectileSpeed();

boolean isSpawnIfNoHome();
}
5 changes: 5 additions & 0 deletions Essentials/src/com/earth2me/essentials/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -1624,4 +1624,9 @@ private double _getMaxProjectileSpeed() {
public double getMaxProjectileSpeed() {
return maxProjectileSpeed;
}

@Override
public boolean isSpawnIfNoHome() {
return config.getBoolean("spawn-if-no-home", true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ public void run(final Server server, final User user, final String commandLabel,
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)) {
Expand Down
3 changes: 3 additions & 0 deletions Essentials/src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8826999

Please sign in to comment.