Archiviert
13
0

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.
Dieser Commit ist enthalten in:
md_5 2014-04-15 10:32:55 +10:00
Ursprung 64eb4b8327
Commit dff782210a
2 geänderte Dateien mit 104 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -1,4 +1,4 @@
From eadd6050bbe94c461d8664a57f5c43073ceee139 Mon Sep 17 00:00:00 2001
From 3b1f422c789b9404a7b7e185dc479ac12dafb624 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sun, 1 Dec 2013 15:10:48 +1100
Subject: [PATCH] mc-dev imports
@ -1274,6 +1274,60 @@ index 0000000..90a2a80
+ c.put(ChunkCoordinates.class, Integer.valueOf(6));
+ }
+}
diff --git a/src/main/java/net/minecraft/server/GameProfileBanEntry.java b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
new file mode 100644
index 0000000..33cfdb2
--- /dev/null
+++ b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
@@ -0,0 +1,48 @@
+package net.minecraft.server;
+
+import java.util.Date;
+import java.util.UUID;
+
+import net.minecraft.util.com.google.gson.JsonObject;
+import net.minecraft.util.com.mojang.authlib.GameProfile;
+
+public class GameProfileBanEntry extends ExpirableListEntry {
+
+ public GameProfileBanEntry(GameProfile gameprofile) {
+ this(gameprofile, (Date) null, (String) null, (Date) null, (String) null);
+ }
+
+ public GameProfileBanEntry(GameProfile gameprofile, Date date, String s, Date date1, String s1) {
+ super(gameprofile, date1, s, date1, s1);
+ }
+
+ public GameProfileBanEntry(JsonObject jsonobject) {
+ super(b(jsonobject), jsonobject);
+ }
+
+ protected void a(JsonObject jsonobject) {
+ if (this.f() != null) {
+ jsonobject.addProperty("uuid", ((GameProfile) this.f()).getId() == null ? "" : ((GameProfile) this.f()).getId().toString());
+ jsonobject.addProperty("name", ((GameProfile) this.f()).getName());
+ super.a(jsonobject);
+ }
+ }
+
+ private static GameProfile b(JsonObject jsonobject) {
+ if (jsonobject.has("uuid") && jsonobject.has("name")) {
+ String s = jsonobject.get("uuid").getAsString();
+
+ UUID uuid;
+
+ try {
+ uuid = UUID.fromString(s);
+ } catch (Throwable throwable) {
+ return null;
+ }
+
+ return new GameProfile(uuid, jsonobject.get("name").getAsString());
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/NBTBase.java b/src/main/java/net/minecraft/server/NBTBase.java
new file mode 100644
index 0000000..02206f5

Datei anzeigen

@ -0,0 +1,49 @@
From 5bcd3aaed63f03a3476f8dbeb0011c521d533b5c Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Tue, 15 Apr 2014 10:32:48 +1000
Subject: [PATCH] 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.
diff --git a/src/main/java/net/minecraft/server/GameProfileBanEntry.java b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
index 33cfdb2..3738b3e 100644
--- a/src/main/java/net/minecraft/server/GameProfileBanEntry.java
+++ b/src/main/java/net/minecraft/server/GameProfileBanEntry.java
@@ -29,20 +29,29 @@ public class GameProfileBanEntry extends ExpirableListEntry {
}
private static GameProfile b(JsonObject jsonobject) {
- if (jsonobject.has("uuid") && jsonobject.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 (jsonobject.has("uuid")) {
String s = jsonobject.get("uuid").getAsString();
- UUID uuid;
-
try {
uuid = UUID.fromString(s);
} catch (Throwable throwable) {
- return null;
}
- return new GameProfile(uuid, jsonobject.get("name").getAsString());
+ }
+ if ( jsonobject.has("name"))
+ {
+ name = jsonobject.get("name").getAsString();
+ }
+ if ( uuid != null || name != null )
+ {
+ return new GameProfile( uuid, name );
} else {
return null;
}
+ // Spigot End
}
}
--
1.8.3.2