13
0
geforkt von Mirrors/Paper

SPIGOT-7047: Add Player#getLastDeathLocation

By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2022-06-10 09:56:52 +10:00
Ursprung 70106be465
Commit 85ee50d5f1
2 geänderte Dateien mit 26 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -6,6 +6,8 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import net.minecraft.core.GlobalPos;
import net.minecraft.nbt.DynamicOpsNBT;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.players.WhiteListEntry; import net.minecraft.server.players.WhiteListEntry;
import net.minecraft.stats.ServerStatisticManager; import net.minecraft.stats.ServerStatisticManager;
@ -19,6 +21,7 @@ import org.bukkit.Server;
import org.bukkit.Statistic; import org.bukkit.Statistic;
import org.bukkit.configuration.serialization.ConfigurationSerializable; import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs; import org.bukkit.configuration.serialization.SerializableAs;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
import org.bukkit.craftbukkit.profile.CraftPlayerProfile; import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -247,6 +250,14 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return getData() != null; 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 @Override
public Location getBedSpawnLocation() { public Location getBedSpawnLocation() {
NBTTagCompound data = getData(); NBTTagCompound data = getData();

Datei anzeigen

@ -36,6 +36,7 @@ import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
import org.bukkit.craftbukkit.event.CraftEventFactory; import org.bukkit.craftbukkit.event.CraftEventFactory;
import org.bukkit.craftbukkit.inventory.CraftContainer; import org.bukkit.craftbukkit.inventory.CraftContainer;
import org.bukkit.craftbukkit.inventory.CraftInventory; import org.bukkit.craftbukkit.inventory.CraftInventory;
@ -646,4 +647,18 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
public void setStarvationRate(int i) { public void setStarvationRate(int i) {
getHandle().getFoodData().starvationRate = 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)));
}
}
} }