summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/JsonList.java
diff options
context:
space:
mode:
authorThinkofdeath <thinkofdeath@spigotmc.org>2014-11-26 08:32:16 +1100
committermd_5 <git@md-5.net>2014-11-28 17:16:30 +1100
commit24557bc2b37deb6a0edf497d547471832457b1dd (patch)
treec560572889a3b0b34964a0cddb35dc87fda3c914 /src/main/java/net/minecraft/server/JsonList.java
parenta4805dbd77da057cc1ea0bf344379bc6e53ca1f6 (diff)
downloadcraftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.gz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.lz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.tar.xz
craftbukkit-24557bc2b37deb6a0edf497d547471832457b1dd.zip
Update to Minecraft 1.8
For more information please see http://www.spigotmc.org/
Diffstat (limited to 'src/main/java/net/minecraft/server/JsonList.java')
-rw-r--r--src/main/java/net/minecraft/server/JsonList.java166
1 files changed, 0 insertions, 166 deletions
diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java
deleted file mode 100644
index 9d1cb336..00000000
--- a/src/main/java/net/minecraft/server/JsonList.java
+++ /dev/null
@@ -1,166 +0,0 @@
-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.getKey()), 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()]);
- }
-
- // CraftBukkit start
- public Collection<JsonListEntry> getValues() {
- return this.d.values();
- }
- // CraftBukkit end
-
- public boolean isEmpty() {
- 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.hasExpired()) {
- arraylist.add(jsonlistentry.getKey());
- }
- }
-
- 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 { // CraftBukkit - Added throws
- 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 { // CraftBukkit - Added throws
- 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.getKey() != null) {
- this.d.put(this.a(jsonlistentry.getKey()), jsonlistentry);
- }
- }
- }
- }
-}