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();
|
Gson gson = new Gson();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
dataJson = FileUtils.readFileToString(file, StandardCharsets.US_ASCII);
|
dataJson = FileUtils.readFileToString(file, StandardCharsets.UTF_16);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class FileManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void writeDataToFile(SplitsFile splitsFile) throws IOException {
|
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) {
|
public static CategoryData categoryReadOrCreate(CategoryFile file) {
|
||||||
CategoryData data;
|
CategoryData data;
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class CategoryData implements ISplitsData {
|
||||||
@Override
|
@Override
|
||||||
public String toJSON() {
|
public String toJSON() {
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
return gson.toJson(this, CategoryData.class);
|
return gson.toJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getBestSegment(int index) {
|
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.game.Map;
|
||||||
import com.github.stachelbeere1248.zombiesutils.timer.recorder.ISplitsData;
|
import com.github.stachelbeere1248.zombiesutils.timer.recorder.ISplitsData;
|
||||||
|
import com.google.gson.Gson;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -25,12 +26,8 @@ public class GameData implements ISplitsData {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toJSON() {
|
public String toJSON() {
|
||||||
StringBuilder JSON = new StringBuilder("[");
|
Gson gson = new Gson();
|
||||||
for (short segment: segments) {
|
return gson.toJson(this.segments);
|
||||||
JSON.append(segment + ',');
|
|
||||||
}
|
|
||||||
JSON.setCharAt(JSON.length()-1,']');
|
|
||||||
return JSON.toString();
|
|
||||||
}
|
}
|
||||||
public void setSegment(int index, short ticks) {
|
public void setSegment(int index, short ticks) {
|
||||||
segments[index] = ticks;
|
segments[index] = ticks;
|
||||||
|
|
Loading…
Add table
Reference in a new issue