Fix for Craftbukkit Bug 912

This commit is contained in:
snowleo 2011-06-12 02:47:50 +02:00
parent 26c9b34744
commit edefb21142

View File

@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerRespawnEvent;
public class EssentialsSpawnPlayerListener extends PlayerListener public class EssentialsSpawnPlayerListener extends PlayerListener
{ {
@Override @Override
public void onPlayerRespawn(PlayerRespawnEvent event) public void onPlayerRespawn(final PlayerRespawnEvent event)
{ {
final IEssentials ess = Essentials.getStatic(); final IEssentials ess = Essentials.getStatic();
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -25,7 +25,8 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
if (ess.getSettings().getRespawnAtHome()) if (ess.getSettings().getRespawnAtHome())
{ {
Location home = user.getHome(user.getLocation()); Location home = user.getHome(user.getLocation());
if (home == null) { if (home == null)
{
throw new Exception(); throw new Exception();
} }
event.setRespawnLocation(home); event.setRespawnLocation(home);
@ -36,28 +37,38 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{ {
} }
Location spawn = ess.getSpawn().getSpawn(user.getGroup()); Location spawn = ess.getSpawn().getSpawn(user.getGroup());
if (spawn == null) { if (spawn == null)
{
return; return;
} }
event.setRespawnLocation(spawn); event.setRespawnLocation(spawn);
} }
@Override @Override
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
final IEssentials ess = Essentials.getStatic(); final IEssentials ess = Essentials.getStatic();
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
if (!user.isNew()) if (!user.isNew())
{ {
return; return;
} }
user.setNew(false); user.setNew(false);
try { ess.scheduleSyncDelayedTask(new Runnable()
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn())); {
} catch (Exception ex) { public void run()
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex); {
} try
{
user.getTeleport().now(ess.getSpawn().getSpawn(ess.getSettings().getNewbieSpawn()));
}
catch (Exception ex)
{
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
}
}
});
if (ess.getSettings().getAnnounceNewPlayers()) if (ess.getSettings().getAnnounceNewPlayers())
{ {