Skip to content

Commit

Permalink
Revert to old createProfile(UUID, String) logic (#7723)
Browse files Browse the repository at this point in the history
  • Loading branch information
lynxplay committed Apr 22, 2022
1 parent c449f6a commit ef6a1a5
Show file tree
Hide file tree
Showing 12 changed files with 117 additions and 45 deletions.
84 changes: 74 additions & 10 deletions patches/api/0058-Basic-PlayerProfile-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,10 @@ index 0000000000000000000000000000000000000000..7b3b6ef533d32169fbeca389bd61cfc6
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index ece84330d2700db8708d2ae2ab7badf4acb428a8..621420d35378e0038c33892c185216894912f023 100644
index ece84330d2700db8708d2ae2ab7badf4acb428a8..90c875ad60e473c3ec25f209933d48615d0fd6c0 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2092,6 +2092,50 @@ public final class Bukkit {
@@ -2092,6 +2092,83 @@ public final class Bukkit {
public static boolean suggestPlayerNamesWhenNullTabCompletions() {
return server.suggestPlayerNamesWhenNullTabCompletions();
}
Expand All @@ -301,7 +301,7 @@ index ece84330d2700db8708d2ae2ab7badf4acb428a8..621420d35378e0038c33892c18521689
+ * Creates a PlayerProfile for the specified uuid, with name as null.
+ *
+ * If a player with the passed uuid exists on the server at the time of creation, the returned player profile will
+ * be populated with the properties of said player.
+ * be populated with the properties of said player (including their uuid and name).
+ *
+ * @param uuid UUID to create profile for
+ * @return A PlayerProfile object
Expand All @@ -315,7 +315,12 @@ index ece84330d2700db8708d2ae2ab7badf4acb428a8..621420d35378e0038c33892c18521689
+ * Creates a PlayerProfile for the specified name, with UUID as null.
+ *
+ * If a player with the passed name exists on the server at the time of creation, the returned player profile will
+ * be populated with the properties of said player.
+ * be populated with the properties of said player (including their uuid and name).
+ * <p>
+ * E.g. if the player 'jeb_' is currently playing on the server, calling {@code createProfile("JEB_")} will
+ * yield a profile with the name 'jeb_', their uuid and their textures.
+ * To bypass this pre-population on a case-insensitive name match, see {@link #createProfileExact(UUID, String)}.
+ * <p>
+ *
+ * @param name Name to create profile for
+ * @return A PlayerProfile object
Expand All @@ -330,7 +335,15 @@ index ece84330d2700db8708d2ae2ab7badf4acb428a8..621420d35378e0038c33892c18521689
+ *
+ * Both UUID and Name can not be null at same time. One must be supplied.
+ * If a player with the passed uuid or name exists on the server at the time of creation, the returned player
+ * profile will be populated with the properties of said player.
+ * profile will be populated with the properties of said player (including their uuid and name).
+ * <p>
+ * E.g. if the player 'jeb_' is currently playing on the server, calling {@code createProfile(null, "JEB_")} will
+ * yield a profile with the name 'jeb_', their uuid and their textures.
+ * To bypass this pre-population on an case-insensitive name match, see {@link #createProfileExact(UUID, String)}.
+ * <p>
+ *
+ * The name comparison will compare the {@link String#toLowerCase()} version of both the passed name parameter and
+ * a players name to honour the case-insensitive nature of a mojang profile lookup.
+ *
+ * @param uuid UUID to create profile for
+ * @param name Name to create profile for
Expand All @@ -339,15 +352,35 @@ index ece84330d2700db8708d2ae2ab7badf4acb428a8..621420d35378e0038c33892c18521689
+ @NotNull
+ public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
+ return server.createProfile(uuid, name);
+ }
+
+ /**
+ * Creates an exact PlayerProfile for the specified name/uuid
+ *
+ * Both UUID and Name can not be null at same time. One must be supplied.
+ * If a player with the passed uuid or name exists on the server at the time of creation, the returned player
+ * profile will be populated with the properties of said player.
+ * <p>
+ * Compared to {@link #createProfile(UUID, String)}, this method will never mutate the passed uuid or name.
+ * If a player with either the same uuid or a matching name (case-insensitive) is found on the server, their
+ * properties, such as textures, will be pre-populated in the profile, however the passed uuid and name stay intact.
+ *
+ * @param uuid UUID to create profile for
+ * @param name Name to create profile for
+ * @return A PlayerProfile object
+ */
+ @NotNull
+ public static com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name) {
+ return server.createProfileExact(uuid, name);
+ }
// Paper end

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 3c987b2fb0f748ce92a87c4ee54a4e9722e1910e..58c8e74b61dd4d952919a854a374ae7b4c3e02c0 100644
index 3c987b2fb0f748ce92a87c4ee54a4e9722e1910e..9796ae6fcf605af88c1e5c1d29d77ea6857632cc 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1838,5 +1838,43 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1838,5 +1838,74 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return true if player names should be suggested
*/
boolean suggestPlayerNamesWhenNullTabCompletions();
Expand All @@ -356,7 +389,7 @@ index 3c987b2fb0f748ce92a87c4ee54a4e9722e1910e..58c8e74b61dd4d952919a854a374ae7b
+ * Creates a PlayerProfile for the specified uuid, with name as null.
+ *
+ * If a player with the passed uuid exists on the server at the time of creation, the returned player profile will
+ * be populated with the properties of said player.
+ * be populated with the properties of said player (including their uuid and name).
+ *
+ * @param uuid UUID to create profile for
+ * @return A PlayerProfile object
Expand All @@ -368,7 +401,12 @@ index 3c987b2fb0f748ce92a87c4ee54a4e9722e1910e..58c8e74b61dd4d952919a854a374ae7b
+ * Creates a PlayerProfile for the specified name, with UUID as null.
+ *
+ * If a player with the passed name exists on the server at the time of creation, the returned player profile will
+ * be populated with the properties of said player.
+ * be populated with the properties of said player (including their uuid and name).
+ * <p>
+ * E.g. if the player 'jeb_' is currently playing on the server, calling {@code createProfile("JEB_")} will
+ * yield a profile with the name 'jeb_', their uuid and their textures.
+ * To bypass this pre-population on a case-insensitive name match, see {@link #createProfileExact(UUID, String)}.
+ * <p>
+ *
+ * @param name Name to create profile for
+ * @return A PlayerProfile object
Expand All @@ -381,13 +419,39 @@ index 3c987b2fb0f748ce92a87c4ee54a4e9722e1910e..58c8e74b61dd4d952919a854a374ae7b
+ *
+ * Both UUID and Name can not be null at same time. One must be supplied.
+ * If a player with the passed uuid or name exists on the server at the time of creation, the returned player
+ * profile will be populated with the properties of said player.
+ * profile will be populated with the properties of said player (including their uuid and name).
+ * <p>
+ * E.g. if the player 'jeb_' is currently playing on the server, calling {@code createProfile(null, "JEB_")} will
+ * yield a profile with the name 'jeb_', their uuid and their textures.
+ * To bypass this pre-population on an case-insensitive name match, see {@link #createProfileExact(UUID, String)}.
+ * <p>
+ *
+ * The name comparison will compare the {@link String#toLowerCase()} version of both the passed name parameter and
+ * a players name to honour the case-insensitive nature of a mojang profile lookup.
+ *
+ * @param uuid UUID to create profile for
+ * @param name Name to create profile for
+ * @return A PlayerProfile object
+ */
+ @NotNull
+ com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name);
+
+ /**
+ * Creates an exact PlayerProfile for the specified name/uuid
+ *
+ * Both UUID and Name can not be null at same time. One must be supplied.
+ * If a player with the passed uuid or name exists on the server at the time of creation, the returned player
+ * profile will be populated with the properties of said player.
+ * <p>
+ * Compared to {@link #createProfile(UUID, String)}, this method will never mutate the passed uuid or name.
+ * If a player with either the same uuid or a matching name (case-insensitive) is found on the server, their
+ * properties, such as textures, will be pre-populated in the profile, however the passed uuid and name stay intact.
+ *
+ * @param uuid UUID to create profile for
+ * @param name Name to create profile for
+ * @return A PlayerProfile object
+ */
+ @NotNull
+ com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name);
// Paper end
}
14 changes: 7 additions & 7 deletions patches/api/0183-Expose-the-internal-current-tick.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Subject: [PATCH] Expose the internal current tick


diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index c8580174d88674a8ab115976e93f225bb20b5854..af91f6cf87ad0f01370db31720fe318d84786ebd 100644
index 5e145a95c1259e084aeed08a3b1d773843939e3f..070a06b1f19c663063f8803bd3698569f67549b4 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2162,6 +2162,10 @@ public final class Bukkit {
public static com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
return server.createProfile(uuid, name);
@@ -2195,6 +2195,10 @@ public final class Bukkit {
public static com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name) {
return server.createProfileExact(uuid, name);
}
+
+ public static int getCurrentTick() {
Expand All @@ -20,13 +20,13 @@ index c8580174d88674a8ab115976e93f225bb20b5854..af91f6cf87ad0f01370db31720fe318d

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index f673927df360702b07f1fd197a3de07bc47b60cd..dc119a58c02a6b4177d560b70f026db6d9e08c55 100644
index e32e6b87fefa95c07a0aef58cac33c99efea2631..38312ba54a4afd61b002091a742a8c91ecda1b1c 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1898,5 +1898,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1929,5 +1929,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name);
com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name);
+
+ /**
+ * Get the current internal server tick
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0190-Expose-MinecraftServer-isRunning.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ Subject: [PATCH] Expose MinecraftServer#isRunning
This allows for plugins to detect if the server is actually turning off in onDisable rather than just plugins reloading.

diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index a6808ead643db1833e1bb2a5f758f1e1d73059c1..61a60d02557ec83392dc9ce53ac83d8e4060d23b 100644
index d93c189807ca1d22b86ed60e3eb1c1fe0a863495..ffd1c908e56fe4e09def7d7658b59e5827d8ad55 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2185,6 +2185,15 @@ public final class Bukkit {
@@ -2218,6 +2218,15 @@ public final class Bukkit {
public static int getCurrentTick() {
return server.getCurrentTick();
}
Expand All @@ -26,10 +26,10 @@ index a6808ead643db1833e1bb2a5f758f1e1d73059c1..61a60d02557ec83392dc9ce53ac83d8e

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 02139695e15ec52b09ccbdf6105fa2bc786cf9be..fdf88c204505efdb8bd2a51e0f7e0ad1ca803e75 100644
index 81761ca547e6d2283edc5516a115c84cc48016c0..8a71aaf28eb4c38396c330e0d6eac0ed31182c94 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1920,5 +1920,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1951,5 +1951,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return Current tick
*/
int getCurrentTick();
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0200-Add-Mob-Goal-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -523,10 +523,10 @@ index 0000000000000000000000000000000000000000..8fd399f791b45eb7fc62693ca954eea0
+ @Deprecated GoalKey<Mob> UNIVERSAL_ANGER_RESET = GoalKey.of(Mob.class, NamespacedKey.minecraft("universal_anger_reset"));
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index e86d3a012f62e87af1894bf697d496bb82cc6c02..cd175830d73b6db5388d5fcf9c37399f4ccb72e0 100644
index f020e0d840ffb2d4618f226cc698f2d7c1c3858a..a300b85a475364ca5f32a01ae02a77306ea9a1c8 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2206,6 +2206,16 @@ public final class Bukkit {
@@ -2239,6 +2239,16 @@ public final class Bukkit {
public static boolean isStopping() {
return server.isStopping();
}
Expand All @@ -544,10 +544,10 @@ index e86d3a012f62e87af1894bf697d496bb82cc6c02..cd175830d73b6db5388d5fcf9c37399f

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index dda3eb79a9687f8a6fdc9e6bdce3ecdcdfddb5f4..0e7bb5c572aa46120f85e9202dd0fe5cc7943ff5 100644
index 52cb28b85e4ce6f69fea7b8f543aea00c3c7be3b..1360973d22ef5da6388863e8558ef7fe08ae7ec8 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1937,5 +1937,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1968,5 +1968,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
* @return true if server is in the process of being shutdown
*/
boolean isStopping();
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0295-Add-basic-Datapack-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ index 0000000000000000000000000000000000000000..58f78d5e91beacaf710f62461cf869f7
+
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 9f77415577a6ea3f6fda6c3077cdbf123ce47674..fd1ec52f2135914e50dcb9d61635ddab67e46f5a 100644
index a4c09666c3bbb9037303a6eb85d95a2555963aad..90bf75ebd1f6105c5b943c56409d60e3ee35b6b9 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2260,6 +2260,14 @@ public final class Bukkit {
@@ -2293,6 +2293,14 @@ public final class Bukkit {
public static com.destroystokyo.paper.entity.ai.MobGoals getMobGoals() {
return server.getMobGoals();
}
Expand All @@ -89,10 +89,10 @@ index 9f77415577a6ea3f6fda6c3077cdbf123ce47674..fd1ec52f2135914e50dcb9d61635ddab

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index b0cfe2e72d404aca204a0a1a43e4ba4e0c44ac98..da886acceb4cf7129cdc6fe1b4bea2f428597cb7 100644
index afc77648a8863f9d07f89fa1d3b14e88ce4183f6..bcfa12850ace6f3deee546a573f89887cb179892 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1984,5 +1984,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2015,5 +2015,11 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
com.destroystokyo.paper.entity.ai.MobGoals getMobGoals();
Expand Down
8 changes: 4 additions & 4 deletions patches/api/0371-Custom-Potion-Mixes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ index 0000000000000000000000000000000000000000..cb6d93526b637946aec311bef103ad30
+ }
+}
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 6a5b155b4fec18d9aa906cd6cea6394a98cfe1b5..dcfd22862c79ae01ca7707d9abf0a71cc0d4ad9d 100644
index 75bc84ff3280fe7ecfe684014a8865e066b699ab..5979f00d7c85b8807659f1cb40a69f2e2449ef70 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -2319,6 +2319,15 @@ public final class Bukkit {
@@ -2352,6 +2352,15 @@ public final class Bukkit {
public static io.papermc.paper.datapack.DatapackManager getDatapackManager() {
return server.getDatapackManager();
}
Expand All @@ -122,10 +122,10 @@ index 6a5b155b4fec18d9aa906cd6cea6394a98cfe1b5..dcfd22862c79ae01ca7707d9abf0a71c

@NotNull
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 24c3abf0fbc05c1aa22453543be94a2360c59f01..7a3a2ff605e06e42ba2a0263e2c50eed5c24f8e9 100644
index f5ea978dade76db193989f4f92a90578e1c4f67a..b26ff5864d97810202257bed466ea16d9e0a988b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2018,5 +2018,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2049,5 +2049,12 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull
io.papermc.paper.datapack.DatapackManager getDatapackManager();
Expand Down
12 changes: 10 additions & 2 deletions patches/server/0138-Basic-PlayerProfile-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ index c4142568c3188c89142799cc4911dd7eae32a45f..f379e108ec3c762940bddea878a0a711
String s1 = name.toLowerCase(Locale.ROOT);
GameProfileCache.GameProfileInfo usercache_usercacheentry = (GameProfileCache.GameProfileInfo) this.profilesByName.get(s1);
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index 6f1b1191426d864719e1b5cbd42bf5699e6193e3..59f3167c276d93c36b0b36ff0e36918cf498424b 100644
index 6f1b1191426d864719e1b5cbd42bf5699e6193e3..4dad4b95f263bd7cd086d87848ee8c8a862e1577 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -244,6 +244,9 @@ import org.yaml.snakeyaml.error.MarkedYAMLException;
Expand All @@ -642,7 +642,7 @@ index 6f1b1191426d864719e1b5cbd42bf5699e6193e3..59f3167c276d93c36b0b36ff0e36918c
CraftItemFactory.instance();
}

@@ -2574,5 +2578,29 @@ public final class CraftServer implements Server {
@@ -2574,5 +2578,37 @@ public final class CraftServer implements Server {
public boolean suggestPlayerNamesWhenNullTabCompletions() {
return com.destroystokyo.paper.PaperConfig.suggestPlayersWhenNullTabCompletions;
}
Expand All @@ -660,6 +660,14 @@ index 6f1b1191426d864719e1b5cbd42bf5699e6193e3..59f3167c276d93c36b0b36ff0e36918c
+ @Override
+ public com.destroystokyo.paper.profile.PlayerProfile createProfile(@Nullable UUID uuid, @Nullable String name) {
+ Player player = uuid != null ? Bukkit.getPlayer(uuid) : (name != null ? Bukkit.getPlayerExact(name) : null);
+ if (player != null) return new com.destroystokyo.paper.profile.CraftPlayerProfile((CraftPlayer) player);
+
+ return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name);
+ }
+
+ @Override
+ public com.destroystokyo.paper.profile.PlayerProfile createProfileExact(@Nullable UUID uuid, @Nullable String name) {
+ Player player = uuid != null ? Bukkit.getPlayer(uuid) : (name != null ? Bukkit.getPlayerExact(name) : null);
+ if (player == null) return new com.destroystokyo.paper.profile.CraftPlayerProfile(uuid, name);
+
+ if (Objects.equals(uuid, player.getUniqueId()) && Objects.equals(name, player.getName())) {
Expand Down

0 comments on commit ef6a1a5

Please sign in to comment.