blob: 8a89c705282a48183380b6a773f8e05391c7df04 (
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
|
package com.earth2me.essentials.craftbukkit;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.storage.Location;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.minecraft.server.NBTTagCompound;
import net.minecraft.server.WorldNBTStorage;
import org.bukkit.craftbukkit.CraftServer;
public class OfflineBedLocation
{
public static Location getBedLocation(final String playername, final IEssentials ess)
{
try
{
final CraftServer cserver = (CraftServer)ess.getServer();
if (cserver == null)
{
return null;
}
final WorldNBTStorage wnbtStorage = (WorldNBTStorage)cserver.getHandle().playerFileData;
if (wnbtStorage == null)
{
return null;
}
final NBTTagCompound playerStorage = wnbtStorage.getPlayerData(playername);
if (playerStorage == null)
{
return null;
}
if (playerStorage.hasKey("SpawnX") && playerStorage.hasKey("SpawnY") && playerStorage.hasKey("SpawnZ"))
{
String spawnWorld = playerStorage.getString("SpawnWorld");
if ("".equals(spawnWorld))
{
spawnWorld = cserver.getWorlds().get(0).getName();
}
return new Location(spawnWorld, playerStorage.getInt("SpawnX"), playerStorage.getInt("SpawnY"), playerStorage.getInt("SpawnZ"));
}
return null;
}
catch (Throwable ex)
{
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
return null;
}
}
}
|