geforkt von Mirrors/Paper
More improvements to PlayerProfile code
.equals() was wrong clean up createPlayerProfile code don't set profile to null if the complete call fails
Dieser Commit ist enthalten in:
Ursprung
1b8ea6f3bb
Commit
855f21c54e
@ -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..616a7b218
|
||||
index 000000000..63782747c
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/com/destroystokyo/paper/profile/CraftPlayerProfile.java
|
||||
@@ -0,0 +0,0 @@
|
||||
@ -18,7 +18,6 @@ index 000000000..616a7b218
|
||||
+import com.mojang.authlib.properties.Property;
|
||||
+import com.mojang.authlib.properties.PropertyMap;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.UserCache;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.spigotmc.SpigotConfig;
|
||||
+
|
||||
@ -27,6 +26,7 @@ index 000000000..616a7b218
|
||||
+import java.util.AbstractSet;
|
||||
+import java.util.Collection;
|
||||
+import java.util.Iterator;
|
||||
+import java.util.Objects;
|
||||
+import java.util.Set;
|
||||
+import java.util.UUID;
|
||||
+
|
||||
@ -49,27 +49,18 @@ index 000000000..616a7b218
|
||||
+
|
||||
+ private static GameProfile createGameProfile(UUID id, String name) {
|
||||
+ new GameProfile(id, name); // Validate that both are not null
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+ UserCache userCache = server.getUserCache();
|
||||
+ GameProfile profile;
|
||||
+
|
||||
+ if (id == null) {
|
||||
+ profile = getProfileByName(name);
|
||||
+ if (profile != null) {
|
||||
+ id = profile.getId();
|
||||
+ }
|
||||
+ } else {
|
||||
+ profile = userCache.getProfile(id);
|
||||
+ if (profile != null) {
|
||||
+ name = profile.getName();
|
||||
+ }
|
||||
+ profile = MinecraftServer.getServer().getUserCache().getProfile(id);
|
||||
+ }
|
||||
+
|
||||
+ GameProfile resultProfile = new GameProfile(id, name);
|
||||
+ if (profile != null) {
|
||||
+ copyProfileProperties(profile, resultProfile);
|
||||
+ if (profile == null) {
|
||||
+ profile = new GameProfile(id, name);
|
||||
+ }
|
||||
+ return resultProfile;
|
||||
+ return profile;
|
||||
+ }
|
||||
+
|
||||
+ private static GameProfile getProfileByName(String name) {
|
||||
@ -130,10 +121,11 @@ index 000000000..616a7b218
|
||||
+ MinecraftServer server = MinecraftServer.getServer();
|
||||
+ String name = profile.getName();
|
||||
+ if (profile.getId() == null) {
|
||||
+ profile = getProfileByName(name);
|
||||
+ GameProfile profile = getProfileByName(name);
|
||||
+ if (profile == null) {
|
||||
+ throw new NullPointerException("Could not get UUID for Player " + name);
|
||||
+ }
|
||||
+ this.profile = profile;
|
||||
+ }
|
||||
+ if (!profile.isComplete() || (textures && !hasTextures())) {
|
||||
+ GameProfile result = server.getSessionService().fillProfileProperties(profile, true);
|
||||
@ -196,7 +188,10 @@ index 000000000..616a7b218
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean equals(Object o) {
|
||||
+ return profile.equals(o);
|
||||
+ if (this == o) return true;
|
||||
+ if (o == null || getClass() != o.getClass()) return false;
|
||||
+ CraftPlayerProfile that = (CraftPlayerProfile) o;
|
||||
+ return Objects.equals(profile, that.profile);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren