Fix home functionality bugs:

/home not using bed when enabled
/home not giving teleport warning
This commit is contained in:
KHobbits 2012-12-29 06:43:26 +00:00
parent 0755fbf089
commit 03445e5b9b
2 changed files with 38 additions and 31 deletions

View File

@ -119,10 +119,12 @@ public class Teleport implements Runnable, ITeleport
teleportUser.sendMessage(_("teleportationCommencing")); teleportUser.sendMessage(_("teleportationCommencing"));
try try
{ {
if (respawn) { if (respawn)
{
teleportUser.getTeleport().respawn(cause); teleportUser.getTeleport().respawn(cause);
} }
else { else
{
teleportUser.getTeleport().now(teleportTarget, cause); teleportUser.getTeleport().now(teleportTarget, cause);
} }
cancel(false); cancel(false);
@ -344,6 +346,7 @@ public class Teleport implements Runnable, ITeleport
} }
cancel(false); cancel(false);
warnUser(user, delay);
initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true); initTimer((long)(delay * 1000.0), user, null, chargeFor, cause, true);
teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10); teleTimer = ess.scheduleSyncRepeatingTask(this, 10, 10);
} }
@ -352,12 +355,16 @@ public class Teleport implements Runnable, ITeleport
{ {
final Player player = user.getBase(); final Player player = user.getBase();
Location bed = player.getBedSpawnLocation(); Location bed = player.getBedSpawnLocation();
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK) if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
{ {
now(new Target(bed), cause); now(new Target(bed), cause);
} }
else else
{ {
if (ess.getSettings().isDebug())
{
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
}
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false); final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
ess.getServer().getPluginManager().callEvent(pre); ess.getServer().getPluginManager().callEvent(pre);
now(new Target(pre.getRespawnLocation()), cause); now(new Target(pre.getRespawnLocation()), cause);

View File

@ -69,7 +69,7 @@ public class Commandhome extends EssentialsCommand
} }
else if (homes.isEmpty()) else if (homes.isEmpty())
{ {
throw new Exception(player == user ? _("noHomeSet") : _("noHomeSetPlayer")); throw new Exception(_("noHomeSetPlayer"));
} }
else if (homes.size() == 1 && player.equals(user)) else if (homes.size() == 1 && player.equals(user))
{ {