mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-02 18:46:13 +00: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
3 changed files with 55 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
||||||
import static com.earth2me.essentials.I18n._;
|
import static com.earth2me.essentials.I18n._;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -740,7 +741,7 @@ public class OfflinePlayer implements Player
|
||||||
@Override
|
@Override
|
||||||
public Location getBedSpawnLocation()
|
public Location getBedSpawnLocation()
|
||||||
{
|
{
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
return OfflineBedLocation.getBedLocation(base.getName(), ess);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -48,6 +48,7 @@ public class Commandhome extends EssentialsCommand
|
||||||
if (bed != null)
|
if (bed != null)
|
||||||
{
|
{
|
||||||
user.getTeleport().teleport(bed, charge);
|
user.getTeleport().teleport(bed, charge);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
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…
Add table
Add a link
Reference in a new issue