mirror of
https://github.com/jie65535/gc-opencommand-plugin.git
synced 2025-10-20 17:12:58 +08:00
Fix deprecated method JsonUtils.loadToClass
This commit is contained in:
@@ -105,8 +105,8 @@ public final class OpenCommandPlugin extends Plugin {
|
|||||||
getLogger().error("[OpenCommand] Unable to save config file.");
|
getLogger().error("[OpenCommand] Unable to save config file.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try (var fileReader = new InputStreamReader(new FileInputStream(configFile))) {
|
||||||
config = JsonUtils.loadToClass(configFile.getAbsolutePath(), OpenCommandConfig.class);
|
config = JsonUtils.loadToClass(fileReader, OpenCommandConfig.class);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
config = new OpenCommandConfig();
|
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.");
|
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.");
|
||||||
@@ -125,8 +125,8 @@ public final class OpenCommandPlugin extends Plugin {
|
|||||||
data = new OpenCommandData();
|
data = new OpenCommandData();
|
||||||
saveData();
|
saveData();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try (var fileReader = new InputStreamReader(new FileInputStream(dataFile))) {
|
||||||
data = JsonUtils.loadToClass(dataFile.getAbsolutePath(), OpenCommandData.class);
|
data = JsonUtils.loadToClass(fileReader, OpenCommandData.class);
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
data = new OpenCommandData();
|
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.");
|
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.");
|
||||||
|
Reference in New Issue
Block a user