mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-16 22:43:14 +01:00
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:
parent
b7597142d3
commit
f1087e18c1
1 changed files with 35 additions and 0 deletions
|
@ -5,3 +5,38 @@
|
||||||
package net.minecraft.server.players;
|
package net.minecraft.server.players;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue