use of com.solinia.solinia.Models.SoliniaPlayer in project solinia3-core by mixxit.
the class JsonCharacterListRepository 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(CharacterLists.values(), new TypeToken<List<SoliniaPlayer>>() {
}.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 " + CharacterLists.size() + " CharacterLists");
} 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.SoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaPlayerFactory method CreatePlayer.
public static ISoliniaPlayer CreatePlayer(Player player, boolean main) throws CoreStateInitException {
// A player is different to a players entity
ISoliniaPlayer soliniaPlayer = new SoliniaPlayer();
soliniaPlayer.setUUID(player.getUniqueId());
soliniaPlayer.setMain(main);
String forename = getRandomNames(5, 1)[0];
String lastname = "";
try {
while (StateManager.getInstance().getPlayerManager().IsNewNameValid(forename, lastname) == false) {
forename = getRandomNames(5, 1)[0];
}
soliniaPlayer.setForename(forename);
soliniaPlayer.setLastname(lastname);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
StateManager.getInstance().getPlayerManager().addPlayer(soliniaPlayer);
soliniaPlayer = SoliniaPlayerAdapter.Adapt(player);
soliniaPlayer.setExperience(0d);
soliniaPlayer.setAAExperience(0d);
soliniaPlayer.setMana(0);
return soliniaPlayer;
}
use of com.solinia.solinia.Models.SoliniaPlayer in project solinia3-core by mixxit.
the class JsonPlayerRepository 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(players.values(), new TypeToken<List<SoliniaPlayer>>() {
}.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 " + players.size() + " players");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations