Added some content to the textgame files and added some stuff to the logic files. Also fixed formating in TravelGUI
This commit is contained in:
@@ -18,20 +18,12 @@ public class FileSaving extends Player implements Serializable {
|
||||
|
||||
try {
|
||||
InputStream in = new FileInputStream(new File("src/saves/playerSave.txt"));
|
||||
ObjectInputStream inObject = new ObjectInputStream(in);
|
||||
Player player = (Player) inObject.readObject();
|
||||
in.close();
|
||||
inObject.close();
|
||||
return player;
|
||||
return getPlayer(in);
|
||||
}
|
||||
catch (Exception e) {
|
||||
try {
|
||||
InputStream in = new FileInputStream(new File("saves/playerSave.txt"));
|
||||
ObjectInputStream inObject = new ObjectInputStream(in);
|
||||
Player player = (Player) inObject.readObject();
|
||||
in.close();
|
||||
inObject.close();
|
||||
return player;
|
||||
return getPlayer(in);
|
||||
}
|
||||
catch(Exception e2){
|
||||
return null;
|
||||
@@ -39,6 +31,14 @@ public class FileSaving extends Player implements Serializable {
|
||||
}
|
||||
}
|
||||
|
||||
private Player getPlayer(InputStream in) throws IOException, ClassNotFoundException {
|
||||
ObjectInputStream inObject = new ObjectInputStream(in);
|
||||
Player player = (Player) inObject.readObject();
|
||||
in.close();
|
||||
inObject.close();
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the file of type player which contains all the player instances
|
||||
* @param player The player object being saved
|
||||
|
||||
Reference in New Issue
Block a user