use of com.solinia.solinia.Models.SoliniaNPCMerchant in project solinia3-core by mixxit.
the class JsonNPCMerchantRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
gsonbuilder.registerTypeAdapterFactory(new ISoliniaNPCMerchantEntryTypeAdapterFactory(SoliniaNPCMerchantEntry.class));
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(npcmerchants.values(), new TypeToken<List<SoliniaNPCMerchant>>() {
}.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 " + npcmerchants.size() + " npcmerchants");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Models.SoliniaNPCMerchant in project solinia3-core by mixxit.
the class SoliniaNPCMerchantFactory method CreateNPCMerchant.
public static void CreateNPCMerchant(String name) throws CoreStateInitException {
SoliniaNPCMerchant merchant = new SoliniaNPCMerchant();
merchant.setId(StateManager.getInstance().getConfigurationManager().getNextNPCMerchantId());
merchant.setName(name);
StateManager.getInstance().getConfigurationManager().addNPCMerchant(merchant);
}
Aggregations