cleaned up FileManager.java
This commit is contained in:
parent
dc3923caad
commit
3983ab28b8
3 changed files with 6 additions and 9 deletions
|
@ -19,7 +19,7 @@ public class FileManager {
|
|||
Gson gson = new Gson();
|
||||
|
||||
try {
|
||||
dataJson = FileUtils.readFileToString(file, StandardCharsets.US_ASCII);
|
||||
dataJson = FileUtils.readFileToString(file, StandardCharsets.UTF_16);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class FileManager {
|
|||
}
|
||||
}
|
||||
public static void writeDataToFile(SplitsFile splitsFile) throws IOException {
|
||||
FileUtils.writeStringToFile(splitsFile, splitsFile.getData().toJSON(), StandardCharsets.US_ASCII);
|
||||
FileUtils.writeStringToFile(splitsFile, splitsFile.getData().toJSON(), StandardCharsets.UTF_16);
|
||||
}
|
||||
public static CategoryData categoryReadOrCreate(CategoryFile file) {
|
||||
CategoryData data;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class CategoryData implements ISplitsData {
|
|||
@Override
|
||||
public String toJSON() {
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this, CategoryData.class);
|
||||
return gson.toJson(this);
|
||||
}
|
||||
|
||||
public short getBestSegment(int index) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.github.stachelbeere1248.zombiesutils.timer.recorder.data;
|
|||
|
||||
import com.github.stachelbeere1248.zombiesutils.game.Map;
|
||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.ISplitsData;
|
||||
import com.google.gson.Gson;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -25,12 +26,8 @@ public class GameData implements ISplitsData {
|
|||
|
||||
@Override
|
||||
public String toJSON() {
|
||||
StringBuilder JSON = new StringBuilder("[");
|
||||
for (short segment: segments) {
|
||||
JSON.append(segment + ',');
|
||||
}
|
||||
JSON.setCharAt(JSON.length()-1,']');
|
||||
return JSON.toString();
|
||||
Gson gson = new Gson();
|
||||
return gson.toJson(this.segments);
|
||||
}
|
||||
public void setSegment(int index, short ticks) {
|
||||
segments[index] = ticks;
|
||||
|
|
Loading…
Add table
Reference in a new issue