From 6ad36f09e5173baa3b8f464bae4d0d20411080ec Mon Sep 17 00:00:00 2001 From: Travis Watkins Date: Thu, 17 Apr 2014 03:31:49 -0500 Subject: Fix getting white list, ban list, and op list. Fixes BUKKIT-5538 The getEntries methods on these return player names instead of UUIDs. As we need the UUIDs for our API we add a getValues method to get at the data we need. To further ensure we get the most data possible we also add a way to get at the stored GameProfile to ensure we always have both the UUID and the name from the list. --- src/main/java/net/minecraft/server/JsonList.java | 10 +++++-- .../java/net/minecraft/server/JsonListEntry.java | 2 +- .../minecraft/server/JsonListEntrySerializer.java | 2 ++ .../server/NameReferencingFileConverter.java | 32 ++++++++-------------- 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/main/java/net') diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java index 36df9888..36dbcf62 100644 --- a/src/main/java/net/minecraft/server/JsonList.java +++ b/src/main/java/net/minecraft/server/JsonList.java @@ -79,6 +79,12 @@ public class JsonList { return (String[]) this.d.keySet().toArray(new String[this.d.size()]); } + // CraftBukkit start + public Collection getValues() { + return this.d.values(); + } + // CraftBukkit end + public boolean d() { return this.d.size() < 1; } @@ -120,7 +126,7 @@ public class JsonList { return this.d; } - public void save() { + public void save() throws IOException { // CraftBukkit - Added throws Collection collection = this.d.values(); String s = this.b.toJson(collection); BufferedWriter bufferedwriter = null; @@ -133,7 +139,7 @@ public class JsonList { } } - public void load() { + public void load() throws IOException { // CraftBukkit - Added throws Collection collection = null; BufferedReader bufferedreader = null; diff --git a/src/main/java/net/minecraft/server/JsonListEntry.java b/src/main/java/net/minecraft/server/JsonListEntry.java index 3a7e2c38..e853c564 100644 --- a/src/main/java/net/minecraft/server/JsonListEntry.java +++ b/src/main/java/net/minecraft/server/JsonListEntry.java @@ -14,7 +14,7 @@ public class JsonListEntry { this.a = object; } - Object f() { + public Object f() { // CraftBukkit -> package private -> public return this.a; } diff --git a/src/main/java/net/minecraft/server/JsonListEntrySerializer.java b/src/main/java/net/minecraft/server/JsonListEntrySerializer.java index b6aba6a6..f4eee668 100644 --- a/src/main/java/net/minecraft/server/JsonListEntrySerializer.java +++ b/src/main/java/net/minecraft/server/JsonListEntrySerializer.java @@ -1,5 +1,7 @@ package net.minecraft.server; +// CraftBukkit - Imported for package private use in JsonList + import java.lang.reflect.Type; import net.minecraft.util.com.google.gson.JsonDeserializationContext; diff --git a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java index 45561e9b..a4724312 100644 --- a/src/main/java/net/minecraft/server/NameReferencingFileConverter.java +++ b/src/main/java/net/minecraft/server/NameReferencingFileConverter.java @@ -77,14 +77,12 @@ public class NameReferencingFileConverter { if (b.exists() && b.isFile()) { if (gameprofilebanlist.c().exists()) { - /* CraftBukkit start - Exception is never thrown try { gameprofilebanlist.load(); - } catch (FileNotFoundException filenotfoundexception) { - e.warn("Could not load existing file " + gameprofilebanlist.c().getName(), filenotfoundexception); + // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace + } catch (IOException filenotfoundexception) { + e.warn("Could not load existing file " + gameprofilebanlist.c().getName() + ", " + filenotfoundexception.getMessage()); } - */ - gameprofilebanlist.load(); // CraftBukkit end } @@ -115,14 +113,12 @@ public class NameReferencingFileConverter { if (a.exists() && a.isFile()) { if (ipbanlist.c().exists()) { - /* CraftBukkit start - Exception is never thrown try { ipbanlist.load(); - } catch (FileNotFoundException filenotfoundexception) { - e.warn("Could not load existing file " + ipbanlist.c().getName(), filenotfoundexception); + // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace + } catch (IOException filenotfoundexception) { + e.warn("Could not load existing file " + ipbanlist.c().getName() + ", " + filenotfoundexception.getMessage()); } - */ - ipbanlist.load(); // CraftBukkit end } @@ -160,14 +156,12 @@ public class NameReferencingFileConverter { if (c.exists() && c.isFile()) { if (oplist.c().exists()) { - /* CraftBukkit start - Exception is never thrown try { oplist.load(); - } catch (FileNotFoundException filenotfoundexception) { - e.warn("Could not load existing file " + oplist.c().getName(), filenotfoundexception); + // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace + } catch (IOException filenotfoundexception) { + e.warn("Could not load existing file " + oplist.c().getName() + ", " + filenotfoundexception.getMessage()); } - */ - oplist.load(); // CraftBukkit end } @@ -196,14 +190,12 @@ public class NameReferencingFileConverter { if (d.exists() && d.isFile()) { if (whitelist.c().exists()) { - /* CraftBukkit start - Exception is never thrown try { whitelist.load(); - } catch (FileNotFoundException filenotfoundexception) { - e.warn("Could not load existing file " + whitelist.c().getName(), filenotfoundexception); + // CraftBukkit start - FileNotFoundException -> IOException, don't print stacetrace + } catch (IOException filenotfoundexception) { + e.warn("Could not load existing file " + whitelist.c().getName() + ", " + filenotfoundexception.getMessage()); } - */ - whitelist.load(); // CraftBukkit end } -- cgit v1.2.3