#1002: Add Player Profile API

Slight changes may occur as this API is stabilized.

This PR is based on work previously done by DerFrZocker in #938.

By: blablubbabc <lukas@wirsindwir.de>
This commit is contained in:
CraftBukkit/Spigot
2022-02-03 09:25:39 +11:00
parent 0190fa68f9
commit 08891a2e2f
11 changed files with 1159 additions and 6 deletions

View File

@@ -187,6 +187,7 @@ import org.bukkit.craftbukkit.metadata.EntityMetadataStore;
import org.bukkit.craftbukkit.metadata.PlayerMetadataStore;
import org.bukkit.craftbukkit.metadata.WorldMetadataStore;
import org.bukkit.craftbukkit.potion.CraftPotionBrewer;
import org.bukkit.craftbukkit.profile.CraftPlayerProfile;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.craftbukkit.scoreboard.CraftScoreboardManager;
import org.bukkit.craftbukkit.structure.CraftStructureManager;
@@ -244,6 +245,7 @@ import org.bukkit.plugin.messaging.Messenger;
import org.bukkit.plugin.messaging.StandardMessenger;
import org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.profile.PlayerProfile;
import org.bukkit.scheduler.BukkitWorker;
import org.bukkit.structure.StructureManager;
import org.bukkit.util.StringUtil;
@@ -294,6 +296,7 @@ public final class CraftServer implements Server {
static {
ConfigurationSerialization.registerClass(CraftOfflinePlayer.class);
ConfigurationSerialization.registerClass(CraftPlayerProfile.class);
CraftItemFactory.instance();
}
@@ -1643,6 +1646,21 @@ public final class CraftServer implements Server {
return result;
}
@Override
public PlayerProfile createPlayerProfile(UUID uniqueId, String name) {
return new CraftPlayerProfile(uniqueId, name);
}
@Override
public PlayerProfile createPlayerProfile(UUID uniqueId) {
return new CraftPlayerProfile(uniqueId, null);
}
@Override
public PlayerProfile createPlayerProfile(String name) {
return new CraftPlayerProfile(null, name);
}
public OfflinePlayer getOfflinePlayer(GameProfile profile) {
OfflinePlayer player = new CraftOfflinePlayer(this, profile);
offlinePlayers.put(profile.getId(), player);