Skip to content

Commit b173c3e

Browse files
authored
Use access transformers for player profile API (#7468)
1 parent f5b9e07 commit b173c3e

File tree

2 files changed

+14
-82
lines changed

2 files changed

+14
-82
lines changed

build-data/paper.at

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,17 @@ public net.minecraft.world.level.NaturalSpawner SPAWNING_CATEGORIES
267267
# Optimize isValidLocation
268268
public net.minecraft.world.level.chunk.LevelChunkSection states
269269

270-
# Player.setPlayerProfile API
270+
# Player Profile API
271271
public-f net.minecraft.world.entity.player.Player gameProfile
272+
public org.bukkit.craftbukkit.profile.CraftProfileProperty
273+
public org.bukkit.craftbukkit.profile.CraftPlayerTextures
274+
public org.bukkit.craftbukkit.profile.CraftPlayerTextures copyFrom(Lorg/bukkit/profile/PlayerTextures;)V
275+
public org.bukkit.craftbukkit.profile.CraftPlayerTextures rebuildPropertyIfDirty()V
276+
public org.bukkit.craftbukkit.profile.CraftPlayerProfile getProperty(Ljava/lang/String;)Lcom/mojang/authlib/properties/Property;
277+
public org.bukkit.craftbukkit.profile.CraftPlayerProfile setProperty(Ljava/lang/String;Lcom/mojang/authlib/properties/Property;)V
278+
public org.bukkit.craftbukkit.profile.CraftPlayerProfile toString(Lcom/mojang/authlib/properties/PropertyMap;)Ljava/lang/String;
279+
public org.bukkit.craftbukkit.profile.CraftPlayerProfile equals(Lcom/mojang/authlib/properties/PropertyMap;Lcom/mojang/authlib/properties/PropertyMap;)Z
280+
public org.bukkit.craftbukkit.profile.CraftPlayerProfile hashCode(Lcom/mojang/authlib/properties/PropertyMap;)I
272281

273282
# Generator Settings
274283
public net.minecraft.world.level.levelgen.SurfaceRules$Condition

patches/server/0143-Basic-PlayerProfile-API.patch

Lines changed: 4 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ index 909724efb99f88f3de0967b85d539e0ab1bec8e8..e93c743500e3c439cd32757b16025804
664664
// Paper end
665665
}
666666
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
667-
index 3cd37402c1f98d47ea009fa4ea71c85044bbe59f..8e4a1598d31e362bd7b10033460c11cb49f6275e 100644
667+
index 2d49bd6f3f017d43dfaa23cedf35040b64bcdcf8..661d8e9882509700faa9bc10a2e3074c5553af44 100644
668668
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
669669
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerProfile.java
670670
@@ -27,7 +27,7 @@ import org.bukkit.profile.PlayerProfile;
@@ -676,20 +676,6 @@ index 3cd37402c1f98d47ea009fa4ea71c85044bbe59f..8e4a1598d31e362bd7b10033460c11cb
676676

677677
@Nonnull
678678
public static GameProfile validateSkullProfile(@Nonnull GameProfile gameProfile) {
679-
@@ -80,11 +80,11 @@ public final class CraftPlayerProfile implements PlayerProfile {
680-
}
681-
682-
@Nullable
683-
- Property getProperty(String propertyName) {
684-
+ public Property getProperty(String propertyName) { // Paper - public
685-
return Iterables.getFirst(this.properties.get(propertyName), null);
686-
}
687-
688-
- void setProperty(String propertyName, @Nullable Property property) {
689-
+ public void setProperty(String propertyName, @Nullable Property property) { // Paper - public
690-
// Assert: (property == null) || property.getName().equals(propertyName)
691-
this.removeProperty(propertyName);
692-
if (property != null) {
693679
@@ -92,8 +92,10 @@ public final class CraftPlayerProfile implements PlayerProfile {
694680
}
695681
}
@@ -703,33 +689,6 @@ index 3cd37402c1f98d47ea009fa4ea71c85044bbe59f..8e4a1598d31e362bd7b10033460c11cb
703689
}
704690

705691
void rebuildDirtyProperties() {
706-
@@ -168,7 +170,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
707-
return builder.toString();
708-
}
709-
710-
- private static String toString(@Nonnull PropertyMap propertyMap) {
711-
+ public static String toString(@Nonnull PropertyMap propertyMap) { // Paper - public
712-
StringBuilder builder = new StringBuilder();
713-
builder.append("{");
714-
propertyMap.asMap().forEach((propertyName, properties) -> {
715-
@@ -194,7 +196,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
716-
return true;
717-
}
718-
719-
- private static boolean equals(@Nonnull PropertyMap propertyMap, @Nonnull PropertyMap other) {
720-
+ public static boolean equals(@Nonnull PropertyMap propertyMap, @Nonnull PropertyMap other) { // Paper - public
721-
if (propertyMap.size() != other.size()) return false;
722-
// We take the order of properties into account here, because it is
723-
// also relevant in the serialized and NBT forms of GameProfiles.
724-
@@ -221,7 +223,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
725-
return result;
726-
}
727-
728-
- private static int hashCode(PropertyMap propertyMap) {
729-
+ public static int hashCode(PropertyMap propertyMap) { // Paper - public
730-
int result = 1;
731-
for (Property property : propertyMap.values()) {
732-
result = 31 * result + CraftProfileProperty.hashCode(property);
733692
@@ -236,6 +238,7 @@ public final class CraftPlayerProfile implements PlayerProfile {
734693

735694
@Override
@@ -761,19 +720,10 @@ index 3cd37402c1f98d47ea009fa4ea71c85044bbe59f..8e4a1598d31e362bd7b10033460c11cb
761720
}
762721
}
763722
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerTextures.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerTextures.java
764-
index c930b7557b141650d63d6802c26139b14ddab6b9..bf56d4fbd34586190e2d680cc33d125578a0953e 100644
723+
index e5b61bc1f3a4bfccca386360c4920ffb8b768308..ab1fd3fb39bd40fb867432861462db5f866bce6f 100644
765724
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerTextures.java
766725
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftPlayerTextures.java
767-
@@ -14,7 +14,7 @@ import javax.annotation.Nullable;
768-
import org.bukkit.craftbukkit.util.JsonHelper;
769-
import org.bukkit.profile.PlayerTextures;
770-
771-
-final class CraftPlayerTextures implements PlayerTextures {
772-
+public final class CraftPlayerTextures implements PlayerTextures { // Paper - public
773-
774-
static final String PROPERTY_NAME = "textures";
775-
private static final String MINECRAFT_HOST = "textures.minecraft.net";
776-
@@ -48,7 +48,7 @@ final class CraftPlayerTextures implements PlayerTextures {
726+
@@ -48,7 +48,7 @@ public final class CraftPlayerTextures implements PlayerTextures {
777727
}
778728
}
779729

@@ -782,7 +732,7 @@ index c930b7557b141650d63d6802c26139b14ddab6b9..bf56d4fbd34586190e2d680cc33d1255
782732

783733
// The textures data is loaded lazily:
784734
private boolean loaded = false;
785-
@@ -67,11 +67,11 @@ final class CraftPlayerTextures implements PlayerTextures {
735+
@@ -67,7 +67,7 @@ public final class CraftPlayerTextures implements PlayerTextures {
786736
// GameProfiles (even if these modifications are later reverted).
787737
private boolean dirty = false;
788738

@@ -791,30 +741,3 @@ index c930b7557b141650d63d6802c26139b14ddab6b9..bf56d4fbd34586190e2d680cc33d1255
791741
this.profile = profile;
792742
}
793743

794-
- void copyFrom(@Nonnull PlayerTextures other) {
795-
+ public void copyFrom(@Nonnull PlayerTextures other) { // Paper - public
796-
if (other == this) return;
797-
Preconditions.checkArgument(other instanceof CraftPlayerTextures, "Expecting CraftPlayerTextures, got %s", other.getClass().getName());
798-
CraftPlayerTextures otherTextures = (CraftPlayerTextures) other;
799-
@@ -238,7 +238,7 @@ final class CraftPlayerTextures implements PlayerTextures {
800-
return this.profile.getProperty(PROPERTY_NAME);
801-
}
802-
803-
- void rebuildPropertyIfDirty() {
804-
+ public void rebuildPropertyIfDirty() { // Paper - public
805-
if (!this.dirty) return;
806-
// Assert: loaded
807-
this.dirty = false;
808-
diff --git a/src/main/java/org/bukkit/craftbukkit/profile/CraftProfileProperty.java b/src/main/java/org/bukkit/craftbukkit/profile/CraftProfileProperty.java
809-
index 0617ad166dd4cb5e26c0c22b264116c23b50195b..07348f0d2c61a78610c5f7bdb280b5a39633a831 100644
810-
--- a/src/main/java/org/bukkit/craftbukkit/profile/CraftProfileProperty.java
811-
+++ b/src/main/java/org/bukkit/craftbukkit/profile/CraftProfileProperty.java
812-
@@ -21,7 +21,7 @@ import javax.annotation.Nullable;
813-
import org.apache.commons.io.IOUtils;
814-
import org.bukkit.craftbukkit.configuration.ConfigSerializationUtil;
815-
816-
-final class CraftProfileProperty {
817-
+public final class CraftProfileProperty { // Paper - public
818-
819-
/**
820-
* Different JSON formatting styles to use for encoded property values.

0 commit comments

Comments
 (0)