mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-20 23:46:57 +01:00
SPIGOT-7047: Add Player#getLastDeathLocation
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
70106be465
commit
85ee50d5f1
2 changed files with 26 additions and 0 deletions
|
@ -6,6 +6,8 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import net.minecraft.core.GlobalPos;
|
||||
import net.minecraft.nbt.DynamicOpsNBT;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.server.players.WhiteListEntry;
|
||||
import net.minecraft.stats.ServerStatisticManager;
|
||||
|
@ -19,6 +21,7 @@ import org.bukkit.Server;
|
|||
import org.bukkit.Statistic;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.SerializableAs;
|
||||
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
|
||||
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -247,6 +250,14 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
|
|||
return getData() != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastDeathLocation() {
|
||||
if (getData().contains("LastDeathLocation", 10)) {
|
||||
return GlobalPos.CODEC.parse(DynamicOpsNBT.INSTANCE, getData().get("LastDeathLocation")).result().map(CraftMemoryMapper::fromNms).orElse(null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation() {
|
||||
NBTTagCompound data = getData();
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
|
||||
import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
import org.bukkit.craftbukkit.inventory.CraftContainer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventory;
|
||||
|
@ -646,4 +647,18 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
|
|||
public void setStarvationRate(int i) {
|
||||
getHandle().getFoodData().starvationRate = i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLastDeathLocation() {
|
||||
return getHandle().getLastDeathLocation().map(CraftMemoryMapper::fromNms).orElse(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDeathLocation(Location location) {
|
||||
if (location == null) {
|
||||
getHandle().setLastDeathLocation(Optional.empty());
|
||||
} else {
|
||||
getHandle().setLastDeathLocation(Optional.of(CraftMemoryMapper.toNms(location)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue