mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-26 01:51:42 +01:00
Allows to be teleported to bed location of offline players.
Also adds missing return in /home command
This commit is contained in:
parent
8d4d8effa0
commit
1f1b6aff54
@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
@ -740,7 +741,7 @@ public class OfflinePlayer implements Player
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
return OfflineBedLocation.getBedLocation(base.getName(), ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,6 +48,7 @@ public class Commandhome extends EssentialsCommand
|
||||
if (bed != null)
|
||||
{
|
||||
user.getTeleport().teleport(bed, charge);
|
||||
return;
|
||||
}
|
||||
}
|
||||
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
|
@ -0,0 +1,52 @@
|
||||
package com.earth2me.essentials.craftbukkit;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.NBTTagCompound;
|
||||
import net.minecraft.server.WorldNBTStorage;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
|
||||
|
||||
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(cserver.getWorld(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;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user