/*
 * Copyright (c) 2016 MCPhoton <http://mcphoton.org> and contributors.
 *
 * This file is part of the Photon API <https://github.com/mcphoton/Photon-API>.
 *
 * The Photon API is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * The Photon API is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.mcphoton.config;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Map;

/**
 * A NBT configuration.
 *
 * @see http://wiki.vg/NBT
 * @author TheElectronWill
 */
public class NbtConfiguration extends BaseConfiguration {

	private final String name;

	public NbtConfiguration() {
		super();
		name = "";
	}

	public NbtConfiguration(Map<String, Object> data) {
		super(data);
		name = "";
	}

	public NbtConfiguration(Map<String, Object> data, String name) {
		super(data);
		this.name = name;
	}

	public String getName() {
		return name;
	}

	public boolean containsByteArray(String key) {
		return get(key) instanceof byte[];
	}

	public boolean containsIntArray(String key) {
		return get(key) instanceof int[];
	}

	public byte[] getByteArray(String key) {
		return (byte[]) get(key);
	}

	public int[] getIntArray(String key) {
		return (int[]) get(key);
	}

	@Override
	public void readFrom(InputStream in) throws IOException {
	}

	@Override
	public void writeTo(OutputStream out) throws IOException {
		// defined by the photon's implementation
	}

}

@@ -105,19 +105,37 @@
  Photon 
-API
+Server Implementation
  %3Chttps:
@@ -163,19 +163,22 @@
 /Photon-
-API
+Server
 %3E.%0A *%0A *
@@ -185,27 +185,45 @@
  The Photon 
-API
+Server Implementation
  is free sof
@@ -292,38 +292,38 @@
 erms of the GNU 
-Less
+Aff
 er
+o
  General Public 
@@ -475,11 +475,29 @@
 ton 
-API
+Server Implementation
  is 
@@ -677,30 +677,30 @@
  the%0A * GNU 
-Less
+Aff
 er
+o
  General Pub
@@ -782,14 +782,14 @@
 GNU 
-Less
+Aff
 er
+o
  Gen
@@ -925,106 +925,395 @@
 ort 
-java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.util.Map
+com.electronwill.nbt.Nbt;%0Aimport com.electronwill.nbt.NbtReader;%0Aimport com.electronwill.nbt.ReadTagCompound;%0Aimport com.electronwill.utils.DataInputBuffer;%0Aimport java.io.IOException;%0Aimport java.io.InputStream;%0Aimport java.io.OutputStream;%0Aimport java.nio.ByteBuffer;%0Aimport java.util.Map;%0Aimport org.mcphoton.network.ProtocolOutputStream;%0Aimport org.mcphoton.network.ProtocolWriteable
 ;%0A%0A/
@@ -1456,16 +1456,45 @@
 uration 
+implements ProtocolWriteable 
 %7B%0A%0A%09priv
@@ -1501,13 +1501,16 @@
 ate 
-final
+volatile
  Str
@@ -1805,32 +1805,92 @@
 eturn name;%0A%09%7D%0A%0A
+%09public void setName(String name) %7B%0A%09%09this.name = name;%0A%09%7D%0A%0A
 %09public boolean 
@@ -2269,125 +2269,526 @@
  %7B%0A%09
-%7D%0A%0A%09@Override%0A%09public void writeTo(OutputStream out) throws IOException %7B%0A%09%09// defined by the photon's implementation
+%09ReadTagCompound read = Nbt.read(in);%0A%09%09this.name = read.name;%0A%09%09this.map = read.data;%0A%09%7D%0A%0A%09public void readFrom(ByteBuffer buff) throws IOException %7B%0A%09%09DataInputBuffer dib = new DataInputBuffer(buff);%0A%09%09ReadTagCompound read = new NbtReader(dib).read();%0A%09%09this.name = read.name;%0A%09%09this.map = read.data;%0A%09%7D%0A%0A%09@Override%0A%09public void writeTo(OutputStream out) throws IOException %7B%0A%09%09Nbt.write(map, name, out);%0A%09%7D%0A%0A%09@Override%0A%09public void writeTo(ProtocolOutputStream out) throws IOException %7B%0A%09%09Nbt.write(map, name, out);
 %0A%09%7D%0A

Fix license and implement read & write