13
0
geforkt von Mirrors/Paper

#1329: Add method to get an offline player's location

By: Nothixal <nothixal@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2024-01-15 20:30:41 +11:00
Ursprung 93df3d859c
Commit e216f2ef2d

Datei anzeigen

@ -12,6 +12,7 @@ import java.util.UUID;
import net.minecraft.core.GlobalPos;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.server.players.WhiteListEntry;
import net.minecraft.stats.ServerStatisticManager;
import net.minecraft.world.level.storage.WorldNBTStorage;
@ -269,6 +270,31 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return null;
}
@Override
public Location getLocation() {
NBTTagCompound data = getData();
if (data == null) {
return null;
}
if (data.contains("Pos") && data.contains("Rotation")) {
NBTTagList position = (NBTTagList) data.get("Pos");
NBTTagList rotation = (NBTTagList) data.get("Rotation");
UUID uuid = new UUID(data.getLong("WorldUUIDMost"), data.getLong("WorldUUIDLeast"));
return new Location(server.getWorld(uuid),
position.getDouble(0),
position.getDouble(1),
position.getDouble(2),
rotation.getFloat(0),
rotation.getFloat(1)
);
}
return null;
}
@Override
public Location getBedSpawnLocation() {
NBTTagCompound data = getData();