Skip to content

Commit

Permalink
Fix deprecated method JsonUtils.loadToClass
Browse files Browse the repository at this point in the history
  • Loading branch information
jie65535 committed Feb 18, 2023
1 parent 5c2be0e commit 70261df
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ private void loadConfig() {
getLogger().error("[OpenCommand] Unable to save config file.");
}
} else {
try {
config = JsonUtils.loadToClass(configFile.getAbsolutePath(), OpenCommandConfig.class);
try (var fileReader = new InputStreamReader(new FileInputStream(configFile))) {
config = JsonUtils.loadToClass(fileReader, OpenCommandConfig.class);
} catch (Exception exception) {
config = new OpenCommandConfig();
getLogger().error("[OpenCommand] There was an error while trying to load the configuration from config.json. Please make sure that there are no syntax errors. If you want to start with a default configuration, delete your existing config.json.");
Expand All @@ -125,8 +125,8 @@ private void loadData() {
data = new OpenCommandData();
saveData();
} else {
try {
data = JsonUtils.loadToClass(dataFile.getAbsolutePath(), OpenCommandData.class);
try (var fileReader = new InputStreamReader(new FileInputStream(dataFile))) {
data = JsonUtils.loadToClass(fileReader, OpenCommandData.class);
} catch (Exception exception) {
data = new OpenCommandData();
getLogger().error("[OpenCommand] There was an error while trying to load the data from data.json. Please make sure that there are no syntax errors. If you want to start with a default data, delete your existing data.json.");
Expand Down

0 comments on commit 70261df

Please sign in to comment.