Search in sources :

Example 1 with SoliniaAlignment

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

the class JsonAlignmentRepository method commit.

@Override
public void commit() {
    // TODO Auto-generated method stub
    GsonBuilder gsonbuilder = new GsonBuilder();
    // gsonbuilder.setPrettyPrinting();
    Gson gson = gsonbuilder.create();
    String jsonOutput = gson.toJson(alignments.values(), new TypeToken<List<SoliniaAlignment>>() {
    }.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 " + alignments.size() + " Alignments");
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : ISoliniaAlignment(com.solinia.solinia.Interfaces.ISoliniaAlignment) SoliniaAlignment(com.solinia.solinia.Models.SoliniaAlignment) GsonBuilder(com.google.gson.GsonBuilder) TypeToken(com.google.gson.reflect.TypeToken) FileOutputStream(java.io.FileOutputStream) FileNotFoundException(java.io.FileNotFoundException) Gson(com.google.gson.Gson) OutputStreamWriter(java.io.OutputStreamWriter) IOException(java.io.IOException) File(java.io.File)

Example 2 with SoliniaAlignment

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

the class ConfigurationManager method addAlignment.

@Override
public void addAlignment(String alignmentname) throws Exception {
    for (ISoliniaAlignment alignment : getAlignments()) {
        if (alignment.getName().equals(alignmentname.toUpperCase()))
            throw new Exception("Alignment already exists");
    }
    SoliniaAlignment alignment = new SoliniaAlignment();
    alignment.setId(getNextAlignmentId());
    alignment.setName(alignmentname);
    alignmentsRepository.add(alignment);
}
Also used : SoliniaAlignment(com.solinia.solinia.Models.SoliniaAlignment) ISoliniaAlignment(com.solinia.solinia.Interfaces.ISoliniaAlignment) ISoliniaAlignment(com.solinia.solinia.Interfaces.ISoliniaAlignment) InvalidCraftSettingException(com.solinia.solinia.Exceptions.InvalidCraftSettingException) InvalidNPCEventSettingException(com.solinia.solinia.Exceptions.InvalidNPCEventSettingException) InvalidNpcSettingException(com.solinia.solinia.Exceptions.InvalidNpcSettingException) InvalidSpellSettingException(com.solinia.solinia.Exceptions.InvalidSpellSettingException) InvalidItemSettingException(com.solinia.solinia.Exceptions.InvalidItemSettingException) InvalidAASettingException(com.solinia.solinia.Exceptions.InvalidAASettingException) InvalidFactionSettingException(com.solinia.solinia.Exceptions.InvalidFactionSettingException) InvalidLootTableSettingException(com.solinia.solinia.Exceptions.InvalidLootTableSettingException) InvalidRaceSettingException(com.solinia.solinia.Exceptions.InvalidRaceSettingException) IOException(java.io.IOException) InvalidSpawnGroupSettingException(com.solinia.solinia.Exceptions.InvalidSpawnGroupSettingException) InvalidClassSettingException(com.solinia.solinia.Exceptions.InvalidClassSettingException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) InvalidLootDropSettingException(com.solinia.solinia.Exceptions.InvalidLootDropSettingException) InvalidZoneSettingException(com.solinia.solinia.Exceptions.InvalidZoneSettingException)

Aggregations

ISoliniaAlignment (com.solinia.solinia.Interfaces.ISoliniaAlignment)2 SoliniaAlignment (com.solinia.solinia.Models.SoliniaAlignment)2 IOException (java.io.IOException)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 TypeToken (com.google.gson.reflect.TypeToken)1 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)1 InvalidAASettingException (com.solinia.solinia.Exceptions.InvalidAASettingException)1 InvalidClassSettingException (com.solinia.solinia.Exceptions.InvalidClassSettingException)1 InvalidCraftSettingException (com.solinia.solinia.Exceptions.InvalidCraftSettingException)1 InvalidFactionSettingException (com.solinia.solinia.Exceptions.InvalidFactionSettingException)1 InvalidItemSettingException (com.solinia.solinia.Exceptions.InvalidItemSettingException)1 InvalidLootDropSettingException (com.solinia.solinia.Exceptions.InvalidLootDropSettingException)1 InvalidLootTableSettingException (com.solinia.solinia.Exceptions.InvalidLootTableSettingException)1 InvalidNPCEventSettingException (com.solinia.solinia.Exceptions.InvalidNPCEventSettingException)1 InvalidNpcSettingException (com.solinia.solinia.Exceptions.InvalidNpcSettingException)1 InvalidRaceSettingException (com.solinia.solinia.Exceptions.InvalidRaceSettingException)1 InvalidSpawnGroupSettingException (com.solinia.solinia.Exceptions.InvalidSpawnGroupSettingException)1 InvalidSpellSettingException (com.solinia.solinia.Exceptions.InvalidSpellSettingException)1 InvalidZoneSettingException (com.solinia.solinia.Exceptions.InvalidZoneSettingException)1