Fix Player Banning

This issue stems from the fact that Bukkit's API only allows a UUID to be banned, but Minecraft requires both a UUID and name. To fix this we modify the code to require a UUID or a name, or both. The correct fix would be expanding the API to be able to provide a name, however this would require plugin changes.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2014-04-15 10:32:48 +10:00
parent b7597142d3
commit f1087e18c1

View file

@ -5,3 +5,38 @@
package net.minecraft.server.players;
import com.google.gson.JsonObject;
@@ -39,20 +40,29 @@
@Nullable
private static GameProfile createGameProfile(JsonObject json) {
- if (json.has("uuid") && json.has("name")) {
+ // Spigot start
+ // this whole method has to be reworked to account for the fact Bukkit only accepts UUID bans and gives no way for usernames to be stored!
+ UUID uuid = null;
+ String name = null;
+ if (json.has("uuid")) {
String s = json.get("uuid").getAsString();
- UUID uuid;
-
try {
uuid = UUID.fromString(s);
} catch (Throwable throwable) {
- return null;
}
- return new GameProfile(uuid, json.get("name").getAsString());
+ }
+ if ( json.has("name"))
+ {
+ name = json.get("name").getAsString();
+ }
+ if ( uuid != null || name != null )
+ {
+ return new GameProfile( uuid, name );
} else {
return null;
}
+ // Spigot End
}
}