Basic PlayerProfile API

Establishes base extension of profile systems for future edits too

== AT ==
public org.bukkit.craftbukkit.profile.CraftProfileProperty
public org.bukkit.craftbukkit.profile.CraftPlayerTextures
public org.bukkit.craftbukkit.profile.CraftPlayerTextures copyFrom(Lorg/bukkit/profile/PlayerTextures;)V
public org.bukkit.craftbukkit.profile.CraftPlayerTextures rebuildPropertyIfDirty()V
public org.bukkit.craftbukkit.profile.CraftPlayerProfile toString(Lcom/mojang/authlib/properties/PropertyMap;)Ljava/lang/String;
public org.bukkit.craftbukkit.profile.CraftPlayerProfile getProperty(Ljava/lang/String;)Lcom/mojang/authlib/properties/Property;
public org.bukkit.craftbukkit.profile.CraftPlayerProfile setProperty(Ljava/lang/String;Lcom/mojang/authlib/properties/Property;)V
This commit is contained in:
Aikar
2018-01-15 22:11:48 -05:00
parent 40654111d1
commit bb90110894
10 changed files with 621 additions and 15 deletions

View File

@@ -31,7 +31,7 @@ import org.bukkit.profile.PlayerTextures;
import org.jetbrains.annotations.ApiStatus;
@SerializableAs("PlayerProfile")
public final class CraftPlayerProfile implements PlayerProfile {
public final class CraftPlayerProfile implements PlayerProfile, com.destroystokyo.paper.profile.SharedPlayerProfile { // Paper
@Nonnull
public static GameProfile validateSkullProfile(@Nonnull GameProfile gameProfile) {
@@ -132,8 +132,10 @@ public final class CraftPlayerProfile implements PlayerProfile {
}
}
void removeProperty(String propertyName) {
this.properties.removeAll(propertyName);
// Paper start - change return value for shared interface
public boolean removeProperty(String propertyName) {
return !this.properties.removeAll(propertyName).isEmpty();
// Paper end
}
void rebuildDirtyProperties() {
@@ -283,6 +285,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
@Override
public Map<String, Object> serialize() {
// Paper - diff on change
Map<String, Object> map = new LinkedHashMap<>();
if (this.uniqueId != null) {
map.put("uniqueId", this.uniqueId.toString());
@@ -296,10 +299,12 @@ public final class CraftPlayerProfile implements PlayerProfile {
this.properties.forEach((propertyName, property) -> propertiesData.add(CraftProfileProperty.serialize(property)));
map.put("properties", propertiesData);
}
// Paper - diff on change
return map;
}
public static CraftPlayerProfile deserialize(Map<String, Object> map) {
// Paper - diff on change
UUID uniqueId = ConfigSerializationUtil.getUuid(map, "uniqueId", true);
String name = ConfigSerializationUtil.getString(map, "name", true);
@@ -313,7 +318,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
profile.properties.put(property.name(), property);
}
}
// Paper - diff on change
return profile;
}
}

View File

@@ -48,7 +48,7 @@ public final class CraftPlayerTextures implements PlayerTextures {
}
}
private final CraftPlayerProfile profile;
private final com.destroystokyo.paper.profile.SharedPlayerProfile profile; // Paper
// The textures data is loaded lazily:
private boolean loaded = false;
@@ -67,7 +67,7 @@ public final class CraftPlayerTextures implements PlayerTextures {
// GameProfiles (even if these modifications are later reverted).
private boolean dirty = false;
CraftPlayerTextures(@Nonnull CraftPlayerProfile profile) {
public CraftPlayerTextures(@Nonnull com.destroystokyo.paper.profile.SharedPlayerProfile profile) { // Paper
this.profile = profile;
}