Revert "Print Warning not Stack Trace."

This reverts commit 7edfec9059.
This commit is contained in:
md_5 2014-04-12 15:29:45 +10:00
parent 7edfec9059
commit 75deb2c530
2 changed files with 1 additions and 259 deletions

View file

@ -1,4 +1,4 @@
From 1526448700ee63759ae0005b3751d5e481663057 Mon Sep 17 00:00:00 2001
From 97931158dba30a063fcac2dccac4be91e89f6fb3 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
@ -1179,227 +1179,6 @@ index 0000000..90a2a80
+ c.put(ChunkCoordinates.class, Integer.valueOf(6));
+ }
+}
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
new file mode 100644
index 0000000..6729249
--- /dev/null
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -0,0 +1,160 @@
+package net.minecraft.server;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.ParameterizedType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+import net.minecraft.util.com.google.common.base.Charsets;
+import net.minecraft.util.com.google.common.collect.Lists;
+import net.minecraft.util.com.google.common.collect.Maps;
+import net.minecraft.util.com.google.common.io.Files;
+import net.minecraft.util.com.google.gson.Gson;
+import net.minecraft.util.com.google.gson.GsonBuilder;
+import net.minecraft.util.com.google.gson.JsonObject;
+import net.minecraft.util.org.apache.commons.io.IOUtils;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class JsonList {
+
+ protected static final Logger a = LogManager.getLogger();
+ protected final Gson b;
+ private final File c;
+ private final Map d = Maps.newHashMap();
+ private boolean e = true;
+ private static final ParameterizedType f = new JsonListType();
+
+ public JsonList(File file1) {
+ this.c = file1;
+ GsonBuilder gsonbuilder = (new GsonBuilder()).setPrettyPrinting();
+
+ gsonbuilder.registerTypeHierarchyAdapter(JsonListEntry.class, new JsonListEntrySerializer(this, (JsonListType) null));
+ this.b = gsonbuilder.create();
+ }
+
+ public boolean isEnabled() {
+ return this.e;
+ }
+
+ public void a(boolean flag) {
+ this.e = flag;
+ }
+
+ public File c() {
+ return this.c;
+ }
+
+ public void add(JsonListEntry jsonlistentry) {
+ this.d.put(this.a(jsonlistentry.f()), jsonlistentry);
+
+ try {
+ this.save();
+ } catch (IOException ioexception) {
+ a.warn("Could not save the list after adding a user.", ioexception);
+ }
+ }
+
+ public JsonListEntry get(Object object) {
+ this.h();
+ return (JsonListEntry) this.d.get(this.a(object));
+ }
+
+ public void remove(Object object) {
+ this.d.remove(this.a(object));
+
+ try {
+ this.save();
+ } catch (IOException ioexception) {
+ a.warn("Could not save the list after removing a user.", ioexception);
+ }
+ }
+
+ public String[] getEntries() {
+ return (String[]) this.d.keySet().toArray(new String[this.d.size()]);
+ }
+
+ public boolean d() {
+ return this.d.size() < 1;
+ }
+
+ protected String a(Object object) {
+ return object.toString();
+ }
+
+ protected boolean d(Object object) {
+ return this.d.containsKey(this.a(object));
+ }
+
+ private void h() {
+ ArrayList arraylist = Lists.newArrayList();
+ Iterator iterator = this.d.values().iterator();
+
+ while (iterator.hasNext()) {
+ JsonListEntry jsonlistentry = (JsonListEntry) iterator.next();
+
+ if (jsonlistentry.e()) {
+ arraylist.add(jsonlistentry.f());
+ }
+ }
+
+ iterator = arraylist.iterator();
+
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+
+ this.d.remove(object);
+ }
+ }
+
+ protected JsonListEntry a(JsonObject jsonobject) {
+ return new JsonListEntry(null, jsonobject);
+ }
+
+ protected Map e() {
+ return this.d;
+ }
+
+ public void save() throws IOException {
+ Collection collection = this.d.values();
+ String s = this.b.toJson(collection);
+ BufferedWriter bufferedwriter = null;
+
+ try {
+ bufferedwriter = Files.newWriter(this.c, Charsets.UTF_8);
+ bufferedwriter.write(s);
+ } finally {
+ IOUtils.closeQuietly(bufferedwriter);
+ }
+ }
+
+ public void load() throws IOException {
+ Collection collection = null;
+ BufferedReader bufferedreader = null;
+
+ try {
+ bufferedreader = Files.newReader(this.c, Charsets.UTF_8);
+ collection = (Collection) this.b.fromJson(bufferedreader, f);
+ } finally {
+ IOUtils.closeQuietly(bufferedreader);
+ }
+
+ if (collection != null) {
+ this.d.clear();
+ Iterator iterator = collection.iterator();
+
+ while (iterator.hasNext()) {
+ JsonListEntry jsonlistentry = (JsonListEntry) iterator.next();
+
+ if (jsonlistentry.f() != null) {
+ this.d.put(this.a(jsonlistentry.f()), jsonlistentry);
+ }
+ }
+ }
+ }
+}
diff --git a/src/main/java/net/minecraft/server/JsonListEntrySerializer.java b/src/main/java/net/minecraft/server/JsonListEntrySerializer.java
new file mode 100644
index 0000000..b6aba6a
--- /dev/null
+++ b/src/main/java/net/minecraft/server/JsonListEntrySerializer.java
@@ -0,0 +1,49 @@
+package net.minecraft.server;
+
+import java.lang.reflect.Type;
+
+import net.minecraft.util.com.google.gson.JsonDeserializationContext;
+import net.minecraft.util.com.google.gson.JsonDeserializer;
+import net.minecraft.util.com.google.gson.JsonElement;
+import net.minecraft.util.com.google.gson.JsonObject;
+import net.minecraft.util.com.google.gson.JsonSerializationContext;
+import net.minecraft.util.com.google.gson.JsonSerializer;
+
+class JsonListEntrySerializer implements JsonDeserializer, JsonSerializer {
+
+ final JsonList a;
+
+ private JsonListEntrySerializer(JsonList jsonlist) {
+ this.a = jsonlist;
+ }
+
+ public JsonElement a(JsonListEntry jsonlistentry, Type type, JsonSerializationContext jsonserializationcontext) {
+ JsonObject jsonobject = new JsonObject();
+
+ jsonlistentry.a(jsonobject);
+ return jsonobject;
+ }
+
+ public JsonListEntry a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
+ if (jsonelement.isJsonObject()) {
+ JsonObject jsonobject = jsonelement.getAsJsonObject();
+ JsonListEntry jsonlistentry = this.a.a(jsonobject);
+
+ return jsonlistentry;
+ } else {
+ return null;
+ }
+ }
+
+ public JsonElement serialize(Object object, Type type, JsonSerializationContext jsonserializationcontext) {
+ return this.a((JsonListEntry) object, type, jsonserializationcontext);
+ }
+
+ public Object deserialize(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
+ return this.a(jsonelement, type, jsondeserializationcontext);
+ }
+
+ JsonListEntrySerializer(JsonList jsonlist, JsonListType jsonlisttype) {
+ this(jsonlist);
+ }
+}
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

View file

@ -1,37 +0,0 @@
From 6e1d18cb391db54c04f8aaa084877a2dd937027b Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 12 Apr 2014 15:18:27 +1000
Subject: [PATCH] Print Warning not Stack Trace.
When loading the data .json files.
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
index 6729249..c52c853 100644
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ b/src/main/java/net/minecraft/server/JsonList.java
@@ -3,6 +3,7 @@ package net.minecraft.server;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.util.ArrayList;
@@ -140,7 +141,13 @@ public class JsonList {
try {
bufferedreader = Files.newReader(this.c, Charsets.UTF_8);
collection = (Collection) this.b.fromJson(bufferedreader, f);
- } finally {
+ }
+ // Spigot Start
+ catch ( FileNotFoundException ex )
+ {
+ org.bukkit.Bukkit.getServer().getLogger().warning( "Could not find file " + this.c + ", creating it." );
+ } // Spigot End
+ finally {
IOUtils.closeQuietly(bufferedreader);
}
--
1.8.3.2