Read history
()
| 147 | * Read history |
| 148 | */ |
| 149 | public static void read(){ |
| 150 | final File historyFile = getHistoryFile(); |
| 151 | final File availableWorldsFile = getAvailableWorldsFile(); |
| 152 | |
| 153 | boolean success = false; |
| 154 | |
| 155 | worldFileHistory.clear(); |
| 156 | |
| 157 | // read history |
| 158 | try { |
| 159 | if(historyFile.exists() && historyFile.canRead()){ |
| 160 | readListJSON(historyFile); |
| 161 | success = true; |
| 162 | } |
| 163 | } catch (Exception ex){ |
| 164 | Logger.getLogger(WorldFileList.class.getName()).log(Level.SEVERE, null, ex); |
| 165 | } |
| 166 | |
| 167 | // fallback: legacy available worlds file |
| 168 | if(!success){ |
| 169 | if(availableWorldsFile.exists() && availableWorldsFile.canRead()){ |
| 170 | readWorldList(availableWorldsFile); |
| 171 | } else { |
| 172 | System.err.println("No world history file or not readable"); |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | // remove nonexistant entries |
| 177 | cleanList(); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Write history |