mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-13 14:37:34 +00:00
Move null bed check to teleport code
This commit is contained in:
parent
a9ace1163f
commit
4f21490ec8
|
@ -2,10 +2,12 @@ package com.earth2me.essentials;
|
||||||
|
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import com.earth2me.essentials.api.ITeleport;
|
import com.earth2me.essentials.api.ITeleport;
|
||||||
|
import com.earth2me.essentials.commands.NoChargeException;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
@ -241,7 +243,7 @@ public class Teleport implements Runnable, ITeleport
|
||||||
{
|
{
|
||||||
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
||||||
{
|
{
|
||||||
teleport(new Target(loc), chargeFor, cause);
|
teleport(new Target(loc), chargeFor, cause);
|
||||||
|
@ -321,10 +323,17 @@ public class Teleport implements Runnable, ITeleport
|
||||||
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
||||||
{
|
{
|
||||||
final Player player = user.getBase();
|
final Player player = user.getBase();
|
||||||
final Location bed = player.getBedSpawnLocation();
|
Location bed = player.getBedSpawnLocation();
|
||||||
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, bed == null ? player.getWorld().getSpawnLocation() : bed, bed != null);
|
if (bed != null && bed.getBlock().getType() != Material.BED_BLOCK)
|
||||||
ess.getServer().getPluginManager().callEvent(pre);
|
{
|
||||||
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
|
teleport(bed, chargeFor, cause);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
||||||
|
ess.getServer().getPluginManager().callEvent(pre);
|
||||||
|
teleport(new Target(pre.getRespawnLocation()), chargeFor, cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//The warp function is a wrapper used to teleport a player to a /warp
|
//The warp function is a wrapper used to teleport a player to a /warp
|
||||||
|
@ -332,7 +341,7 @@ public class Teleport implements Runnable, ITeleport
|
||||||
{
|
{
|
||||||
Location loc = ess.getWarps().getWarp(warp);
|
Location loc = ess.getWarps().getWarp(warp);
|
||||||
user.sendMessage(_("warpingTo", warp));
|
user.sendMessage(_("warpingTo", warp));
|
||||||
teleport(new Target(loc), chargeFor, cause);
|
teleport(new Target(loc), chargeFor, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The back function is a wrapper used to teleport a player /back to their previous location.
|
//The back function is a wrapper used to teleport a player /back to their previous location.
|
||||||
|
|
|
@ -65,13 +65,7 @@ public class Commandhome extends EssentialsCommand
|
||||||
final List<String> homes = player.getHomes();
|
final List<String> homes = player.getHomes();
|
||||||
if (homes.isEmpty() && player.equals(user))
|
if (homes.isEmpty() && player.equals(user))
|
||||||
{
|
{
|
||||||
if (bed != null)
|
|
||||||
{
|
|
||||||
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
|
|
||||||
throw new NoChargeException();
|
|
||||||
}
|
|
||||||
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (homes.isEmpty())
|
else if (homes.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue