blob: aef901acf9b0b7f0efca748e98c11085afb2ec6c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package com.earth2me.essentials.spawn;
import com.earth2me.essentials.Essentials;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerRespawnEvent;
public class EssentialsSpawnPlayerListener extends PlayerListener
{
@Override
public void onPlayerRespawn(PlayerRespawnEvent event)
{
User user = Essentials.getStatic().getUser(event.getPlayer());
try
{
if (Essentials.getStatic().getSettings().getRespawnAtHome())
{
Location home = user.getHome();
if (home == null) {
throw new Exception();
}
event.setRespawnLocation(home);
return;
}
}
catch (Throwable ex)
{
}
Location spawn = Essentials.getSpawn().getSpawn(user.getGroup());
if (spawn == null) {
return;
}
event.setRespawnLocation(spawn);
}
@Override
public void onPlayerJoin(PlayerJoinEvent event)
{
User user = Essentials.getStatic().getUser(event.getPlayer());
if (!user.isNew())
{
return;
}
user.setNew(false);
try {
user.getTeleport().now(Essentials.getSpawn().getSpawn(Essentials.getStatic().getSettings().getNewbieSpawn()));
} catch (Exception ex) {
Logger.getLogger("Minecraft").log(Level.WARNING, Util.i18n("teleportNewPlayerError"), ex);
}
if (Essentials.getStatic().getSettings().getAnnounceNewPlayers())
{
Essentials.getStatic().getServer().broadcastMessage(Essentials.getStatic().getSettings().getAnnounceNewPlayerFormat(user));
}
}
}
|