diff --git a/Spigot-API-Patches/Basic-PlayerProfile-API.patch b/Spigot-API-Patches/Basic-PlayerProfile-API.patch index f6007c0da5..7800f1c0f5 100644 --- a/Spigot-API-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-API-Patches/Basic-PlayerProfile-API.patch @@ -7,7 +7,7 @@ Provides basic elements of a PlayerProfile to be used by future API/events diff --git a/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java new file mode 100644 -index 00000000..f3868f94 +index 00000000..a7b69cab --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/PlayerProfile.java @@ -0,0 +0,0 @@ @@ -37,7 +37,7 @@ index 00000000..f3868f94 + @Nullable UUID getId(); + + /** -+ * @return A copy of this players properties, such as textures. ++ * @return A Mutable set of this players properties, such as textures. + * Values specified here are subject to implementation details. + */ + @Nonnull Set<ProfileProperty> getProperties(); diff --git a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch index 64cb5ef9d8..bf6f27ca42 100644 --- a/Spigot-Server-Patches/Basic-PlayerProfile-API.patch +++ b/Spigot-Server-Patches/Basic-PlayerProfile-API.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Basic PlayerProfile API diff --git a/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java new file mode 100644 -index 000000000..6868ee9a4 +index 000000000..171b1aaf5 --- /dev/null +++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java @@ -0,0 +0,0 @@ @@ -15,10 +15,13 @@ index 000000000..6868ee9a4 +import com.mojang.authlib.GameProfile; +import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; ++import com.oracle.webservices.internal.api.message.PropertySet; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; ++import java.util.AbstractSet; +import java.util.Collection; ++import java.util.Iterator; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; @@ -26,6 +29,7 @@ index 000000000..6868ee9a4 +public class CraftPlayerProfile implements PlayerProfile { + + private final GameProfile profile; ++ private final PropertySet properties; + + /** + * Constructs a new Game Profile with the specified ID and name. @@ -37,11 +41,12 @@ index 000000000..6868ee9a4 + * @throws IllegalArgumentException Both ID and name are either null or empty + */ + public CraftPlayerProfile(UUID id, String name) { -+ this.profile = new GameProfile(id, name); ++ this(new GameProfile(id, name)); + } + + public CraftPlayerProfile(GameProfile profile) { + this.profile = profile; ++ this.properties = new PropertySet(); + } + + public GameProfile getGameProfile() { @@ -57,7 +62,7 @@ index 000000000..6868ee9a4 + @Nonnull + @Override + public Set<ProfileProperty> getProperties() { -+ return profile.getProperties().values().stream().map(CraftPlayerProfile::toBukkit).collect(Collectors.toSet()); ++ return properties; + } + + @Nullable @@ -142,6 +147,53 @@ index 000000000..6868ee9a4 + CraftPlayerProfile craft = ((CraftPlayerProfile) profile); + return craft.getGameProfile(); + } ++ ++ private class PropertySet extends AbstractSet<ProfileProperty> { ++ ++ @Override ++ public Iterator<ProfileProperty> iterator() { ++ Iterator<Property> iterator = profile.getProperties().values().iterator(); ++ return new Iterator<ProfileProperty>() { ++ @Override ++ public boolean hasNext() { ++ return iterator.hasNext(); ++ } ++ ++ @Override ++ public ProfileProperty next() { ++ return toBukkit(iterator.next()); ++ } ++ ++ @Override ++ public void remove() { ++ iterator().remove(); ++ } ++ }; ++ } ++ ++ @Override ++ public int size() { ++ return profile.getProperties().size(); ++ } ++ ++ @Override ++ public boolean add(ProfileProperty property) { ++ setProperty(property); ++ return true; ++ } ++ ++ @Override ++ public boolean addAll(Collection<? extends ProfileProperty> c) { ++ //noinspection unchecked ++ setProperties((Collection<ProfileProperty>) c); ++ return true; ++ } ++ ++ @Override ++ public boolean contains(Object o) { ++ return o instanceof ProfileProperty && profile.getProperties().containsKey(((ProfileProperty) o).getName()); ++ } ++ } +} diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java index 02940d697..4539b5601 100644