Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Copyright (c) 2005-2012, KoLmafia development team
- * http://kolmafia.sourceforge.net/
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * [1] Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * [2] Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * [3] Neither the name "KoLmafia" nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
- package net.sourceforge.kolmafia.webui;
- import net.sourceforge.kolmafia.persistence.AdventureDatabase;
- import net.sourceforge.kolmafia.utilities.StringArray;
- import org.json.*;
- import java.io.*;
- import javax.swing.JOptionPane;
- public class jsonWebUI
- {
- private static StringArray[] adventureTableJSON = new StringArray[ 2 ];
- public static final void makeAdventuresJSON()
- {
- adventureTableJSON[0] = AdventureDatabase.adventureTable[0];
- adventureTableJSON[1] = AdventureDatabase.adventureTable[3];
- JSONStringer mJSONAdventures = new JSONStringer();
- try {
- mJSONAdventures.array();
- } catch (JSONException e) {
- e.printStackTrace();
- }
- for (int i = 0; i < adventureTableJSON[0].size(); i++)
- {
- try {
- mJSONAdventures.object()
- .key("Zone")
- .value(adventureTableJSON[0].get(i))
- .key("Location")
- .value(adventureTableJSON[1].get(i))
- .endObject();
- } catch (JSONException e) { }
- }
- try {
- mJSONAdventures.endArray();
- } catch (JSONException e) { }
- String JSONdata = mJSONAdventures.toString();
- try {
- FileWriter fstream = new FileWriter("relay/adventures.json");
- BufferedWriter out = new BufferedWriter(fstream);
- out.write(JSONdata);
- out.close();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null, "problem making relay/adventure.json" );
- e.printStackTrace();
- }
- }
- public static final void buildInvJSON()
- {
- JSONStringer mJSONInv = new JSONStringer();
- try {
- mJSONInv.array();
- } catch (JSONException e) {
- e.printStackTrace();
- }
- // for (int i = 0; i < adventureTableJSON[0].size(); i++)
- {
- try {
- mJSONInv.object()
- .key("Item")
- // .value(adventureTableJSON[0].get(i))
- .key("Quanity")
- // .value(adventureTableJSON[1].get(i))
- .endObject();
- } catch (JSONException e) { }
- }
- try {
- mJSONInv.endArray();
- } catch (JSONException e) { }
- String JSONdata = mJSONInv.toString();
- try {
- FileWriter fstream = new FileWriter("relay/Inv.json");
- BufferedWriter out = new BufferedWriter(fstream);
- out.write(JSONdata);
- out.close();
- } catch (IOException e) {
- JOptionPane.showMessageDialog(null, "problem making relay/inv.json" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement