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);
}
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();
}
}
Aggregations