Skip to content

Commit

Permalink
Fix a file bug where File went null due to Gson not calling the const…
Browse files Browse the repository at this point in the history
…ructor
  • Loading branch information
Burchard36 committed Dec 8, 2021
1 parent 21d13f5 commit 0429541
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/burchard36/json/JsonDataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class JsonDataFile {

public transient JavaPlugin plugin;
private transient final File file;
public transient File file;

public JsonDataFile(final JavaPlugin plugin,
String pathToFile) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/com/burchard36/json/PluginDataMap.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.burchard36.json;

import com.burchard36.Logger;

import java.util.Collection;
import java.util.HashMap;

Expand All @@ -24,8 +26,12 @@ public void loadDataFile(final String E, final JsonDataFile dataFile) {
if (data == null) {
this.writer.createFile(dataFile);
data = this.writer.getDataFromFile(dataFile.getFile(), dataFile.getClass());
if (data == null) {
Logger.error("YO DUDE!! This file doesnt exists! This is an API Level error, you seriously fucked up or you need to contact the developer because maybe i fucked up. Sorry!");
return;
}
}

data.file = dataFile.getFile(); // We need to set the file again because Gson doesnt call the constructor to get the File
this.dataMapByStrings.putIfAbsent(E, data);
}

Expand Down

0 comments on commit 0429541

Please sign in to comment.