New behavior of the /home command and beds

- The behavior has been altered to match the vanilla server.
 - Using a bed will no longer create a home in the users file, if config option bed-sethome is set
 - The config option bed-sethome has been removed
 - It's now possible to go to /home bed or /home playername:bed
 - Bed locations stored before installing Essentials will be used
 - Players respawn at their bed location (if set) instead of the spawn, if respawn-at-home is set to false
 - The default value of spawn-if-no-home is set to true
 - If spawn-if-no-home is set and the player has not set a home, he will be either teleported to his bed location (if set) or the spawn, when he uses the /home command
This commit is contained in:
snowleo 2011-11-26 22:30:40 +01:00
parent f9d14697b6
commit b21b7b7e15
9 changed files with 70 additions and 93 deletions

View file

@ -6,6 +6,7 @@ import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
import org.bukkit.Server;
@ -42,14 +43,32 @@ public class Commandhome extends EssentialsCommand
}
try
{
if ("bed".equalsIgnoreCase(homeName)) {
final Location bed = player.getBedSpawnLocation();
if (bed != null)
{
user.getTeleport().teleport(bed, charge);
}
}
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
}
catch (NotEnoughArgumentsException e)
{
final List<String> homes = player.getHomes();
if (homes.isEmpty() && player.equals(user) && ess.getSettings().spawnIfNoHome())
if (homes.isEmpty() && player.equals(user))
{
user.getTeleport().respawn(ess.getSpawn(), charge);
final Location loc = player.getBedSpawnLocation();
if (loc == null)
{
if (ess.getSettings().spawnIfNoHome())
{
user.getTeleport().respawn(ess.getSpawn(), charge);
}
}
else
{
user.getTeleport().teleport(loc, charge);
}
}
else if (homes.isEmpty())
{
@ -61,6 +80,7 @@ public class Commandhome extends EssentialsCommand
}
else
{
homes.add("bed");
user.sendMessage(_("homes", Util.joinList(homes)));
}
}