MVWorld.toString() now outputs JSON data.

This commit is contained in:
Jeremy Wood 2012-10-20 12:44:50 -04:00
parent 271e5f339e
commit 6a4921d7d1

View File

@ -39,6 +39,7 @@ import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission; import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault; import org.bukkit.permissions.PermissionDefault;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.json.simple.JSONObject;
import java.lang.ref.Reference; import java.lang.ref.Reference;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
@ -1397,11 +1398,13 @@ public class MVWorld extends SerializationConfig implements MultiverseWorld {
@Override @Override
public String toString() { public String toString() {
StringBuilder toStringBuilder = new StringBuilder(); final JSONObject jsonData = new JSONObject();
toStringBuilder.append(this.getClass().getSimpleName()); jsonData.put("Name", getName());
toStringBuilder.append('@'); jsonData.put("Env", getEnvironment().toString());
toStringBuilder.append(this.hashCode()); jsonData.put("Type", getWorldType().toString());
toStringBuilder.append(" (Name: '").append(this.getName()).append("')"); jsonData.put("Gen", getGenerator());
return toStringBuilder.toString(); final JSONObject topLevel = new JSONObject();
topLevel.put(getClass().getSimpleName() + "@" + hashCode(), jsonData);
return topLevel.toString();
} }
} }