Search in sources :

Example 1 with SoliniaLootTable

use of com.solinia.solinia.Models.SoliniaLootTable in project solinia3-core by mixxit.

the class SoliniaLootFactory method CreateLootTable.

public static void CreateLootTable(String loottablename, boolean operatorCreated) throws CoreStateInitException {
    SoliniaLootTable loottable = new SoliniaLootTable();
    loottable.setId(StateManager.getInstance().getConfigurationManager().getNextLootTableId());
    loottable.setName(loottablename);
    loottable.setOperatorCreated(operatorCreated);
    StateManager.getInstance().getConfigurationManager().addLootTable(loottable);
}
Also used : SoliniaLootTable(com.solinia.solinia.Models.SoliniaLootTable) ISoliniaLootTable(com.solinia.solinia.Interfaces.ISoliniaLootTable)

Example 2 with SoliniaLootTable

use of com.solinia.solinia.Models.SoliniaLootTable in project solinia3-core by mixxit.

the class JsonLootTableRepository method commit.

@Override
public void commit() {
    // TODO Auto-generated method stub
    GsonBuilder gsonbuilder = new GsonBuilder();
    // gsonbuilder.setPrettyPrinting();
    gsonbuilder.registerTypeAdapterFactory(new ISoliniaLootTableEntryTypeAdapterFactory(SoliniaLootTableEntry.class));
    Gson gson = gsonbuilder.create();
    String jsonOutput = gson.toJson(loottables.values(), new TypeToken<List<SoliniaLootTable>>() {
    }.getType());
    try {
        File file = new File(filePath);
        if (!file.exists())
            file.createNewFile();
        FileOutputStream fileOut = new FileOutputStream(file);
        OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
        outWriter.append(jsonOutput);
        outWriter.close();
        fileOut.close();
        System.out.println("Commited " + loottables.size() + " loottables");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ISoliniaLootTableEntryTypeAdapterFactory(com.solinia.solinia.Factories.ISoliniaLootTableEntryTypeAdapterFactory) SoliniaLootTable(com.solinia.solinia.Models.SoliniaLootTable) ISoliniaLootTable(com.solinia.solinia.Interfaces.ISoliniaLootTable) GsonBuilder(com.google.gson.GsonBuilder) TypeToken(com.google.gson.reflect.TypeToken) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) Gson(com.google.gson.Gson) SoliniaLootTableEntry(com.solinia.solinia.Models.SoliniaLootTableEntry) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File)

Aggregations

ISoliniaLootTable (com.solinia.solinia.Interfaces.ISoliniaLootTable)2 SoliniaLootTable (com.solinia.solinia.Models.SoliniaLootTable)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 ISoliniaLootTableEntryTypeAdapterFactory (com.solinia.solinia.Factories.ISoliniaLootTableEntryTypeAdapterFactory)1 SoliniaLootTableEntry (com.solinia.solinia.Models.SoliniaLootTableEntry)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 OutputStreamWriter (java.io.OutputStreamWriter)1