Allow for implementations to provide a custom resource loader

This will allow Geyser-Fabric to work without resource loading issues. This commit also ensures try-with-resources is used anywhere a resource is accessed.
This commit is contained in:
Camotoy 2021-12-03 11:01:06 -05:00
parent 9084c59003
commit 763743a845
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
22 changed files with 220 additions and 211 deletions

View file

@ -71,15 +71,19 @@ public class GeyserSpongePlugin implements GeyserBootstrap {
@Override
public void onEnable() {
GeyserLocale.init(this);
if (!configDir.exists())
configDir.mkdirs();
File configFile = null;
File configFile;
try {
configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml", (file) -> file.replaceAll("generateduuid", UUID.randomUUID().toString()));
configFile = FileUtils.fileOrCopiedFromResource(new File(configDir, "config.yml"), "config.yml",
(file) -> file.replaceAll("generateduuid", UUID.randomUUID().toString()), this);
} catch (IOException ex) {
logger.warn(GeyserLocale.getLocaleStringLog("geyser.config.failed"));
logger.error(GeyserLocale.getLocaleStringLog("geyser.config.failed"));
ex.printStackTrace();
return;
}
try {