diff --git a/patches/api/Basic-PlayerProfile-API.patch b/patches/api/Basic-PlayerProfile-API.patch index 514a9d9db7..a7218d8287 100644 --- a/patches/api/Basic-PlayerProfile-API.patch +++ b/patches/api/Basic-PlayerProfile-API.patch @@ -362,6 +362,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param name Name to create profile for + * @return A PlayerProfile object ++ * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@NotNull String name) { @@ -386,6 +388,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param uuid UUID to create profile for + * @param name Name to create profile for + * @return A PlayerProfile object ++ * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) { @@ -406,6 +410,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param uuid UUID to create profile for + * @param name Name to create profile for + * @return A PlayerProfile object ++ * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + public static com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name) { @@ -448,6 +454,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * + * @param name Name to create profile for + * @return A PlayerProfile object ++ * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + com.destroystokyo.paper.profile.PlayerProfile createProfile(@NotNull String name); @@ -471,6 +479,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param name Name to create profile for + * @return A PlayerProfile object + * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name); @@ -490,6 +499,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + * @param name Name to create profile for + * @return A PlayerProfile object + * @throws IllegalArgumentException if the name is longer than 16 characters ++ * @throws IllegalArgumentException if the name contains invalid characters + */ + @NotNull + com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name); diff --git a/patches/server/Basic-PlayerProfile-API.patch b/patches/server/Basic-PlayerProfile-API.patch index 26f6ad0e2f..29226ee836 100644 --- a/patches/server/Basic-PlayerProfile-API.patch +++ b/patches/server/Basic-PlayerProfile-API.patch @@ -33,6 +33,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 +import net.minecraft.Util; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.players.GameProfileCache; ++import net.minecraft.util.StringUtil; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.bukkit.configuration.serialization.SerializableAs; @@ -292,6 +293,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + + private static GameProfile createAuthLibProfile(UUID uniqueId, String name) { + Preconditions.checkArgument(name == null || name.length() <= 16, "Name cannot be longer than 16 characters"); ++ Preconditions.checkArgument(name == null || StringUtil.isValidPlayerName(name), "The name of the profile contains invalid characters: %s", name); + return new GameProfile( + uniqueId != null ? uniqueId : Util.NIL_UUID, + name != null ? name : "" @@ -678,12 +680,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return new com.destroystokyo.paper.profile.CraftPlayerProfile((CraftPlayer) player); + } + -+ final com.mojang.authlib.GameProfile profile = new com.mojang.authlib.GameProfile( -+ uuid != null ? uuid : net.minecraft.Util.NIL_UUID, -+ name != null ? name : "" -+ ); -+ profile.getProperties().putAll(((CraftPlayer) player).getHandle().getGameProfile().getProperties()); -+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(profile); ++ final com.destroystokyo.paper.profile.CraftPlayerProfile profile = new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name); ++ profile.getGameProfile().getProperties().putAll(((CraftPlayer) player).getHandle().getGameProfile().getProperties()); ++ return profile; + } // Paper end } diff --git a/patches/server/Expose-the-internal-current-tick.patch b/patches/server/Expose-the-internal-current-tick.patch index 0b0b0d0642..142f1a0ef7 100644 --- a/patches/server/Expose-the-internal-current-tick.patch +++ b/patches/server/Expose-the-internal-current-tick.patch @@ -9,8 +9,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -0,0 +0,0 @@ public final class CraftServer implements Server { - profile.getProperties().putAll(((CraftPlayer) player).getHandle().getGameProfile().getProperties()); - return new com.destroystokyo.paper.profile.CraftPlayerProfile(profile); + profile.getGameProfile().getProperties().putAll(((CraftPlayer) player).getHandle().getGameProfile().getProperties()); + return profile; } + + @Override diff --git a/patches/server/Handle-Item-Meta-Inconsistencies.patch b/patches/server/Handle-Item-Meta-Inconsistencies.patch index b36d6df45c..2443ba3da2 100644 --- a/patches/server/Handle-Item-Meta-Inconsistencies.patch +++ b/patches/server/Handle-Item-Meta-Inconsistencies.patch @@ -273,6 +273,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 Preconditions.checkArgument(isValidSkullProfile, "The skull profile is missing a name or textures!"); + // Paper start - Validate + Preconditions.checkArgument(gameProfile.getName().length() <= 16, "The name of the profile is longer than 16 characters"); ++ Preconditions.checkArgument(net.minecraft.util.StringUtil.isValidPlayerName(gameProfile.getName()), "The name of the profile contains invalid characters: %s", gameProfile.getName()); + final PropertyMap properties = gameProfile.getProperties(); + Preconditions.checkArgument(properties.size() <= 16, "The profile contains more than 16 properties"); + for (final Property property : properties.values()) { @@ -289,6 +290,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public CraftPlayerProfile(UUID uniqueId, String name) { Preconditions.checkArgument((uniqueId != null) || !StringUtils.isBlank(name), "uniqueId is null or name is blank"); + Preconditions.checkArgument(name == null || name.length() <= 16, "The name of the profile is longer than 16 characters"); // Paper - Validate ++ Preconditions.checkArgument(name == null || net.minecraft.util.StringUtil.isValidPlayerName(name), "The name of the profile contains invalid characters: %s", name); // Paper - Validate this.uniqueId = (uniqueId == null) ? Util.NIL_UUID : uniqueId; this.name = (name == null) ? "" : name; }