Add verbose check to locale extractor

This commit is contained in:
Ryder Belserion 2023-03-04 23:41:05 -05:00
parent ac6caf62e1
commit 23499e7682
No known key found for this signature in database
GPG Key ID: 8FC2E6C54BBF05FE
3 changed files with 15 additions and 13 deletions

View File

@ -58,7 +58,7 @@ public class PluginSettings implements SettingsHolder {
"Submit your finalized config using https://bin.bloom.host/ and send it to us in https://discord.gg/crazycrew",
""
})
public static final Property<String> LOCALE_FILE = newProperty("settings.locale-file", "en-US");
public static final Property<String> LOCALE_FILE = newProperty("settings.locale-file", "en-US.yml");
@Comment("Whether you want to have verbose logging enabled or not.")
public static final Property<Boolean> VERBOSE_LOGGING = newProperty("settings.verbose-logging", true);

View File

@ -22,18 +22,17 @@ public class FileUtils {
* @param output the output wherever you use this.
* @param replace if we should replace or not.
*/
public static void extract(String input, Path output, boolean replace) {
public static void extract(String input, Path output, boolean replace, boolean verbose) {
URL directory = FileUtils.class.getResource(input);
if (directory == null) CrazyLogger.debug("<#E0115F>Could not find <#11e092>" + input + " <#E0115F>in the jar.");
if (directory == null) if (verbose) CrazyLogger.debug("<#E0115F>Could not find <#11e092>" + input + " <#E0115F>in the jar.");
assert directory != null;
if (!directory.getProtocol().equals("jar"))
CrazyLogger.debug("<#E0115F>Failed because the protocol does not equal .jar!");
if (!directory.getProtocol().equals("jar")) if (verbose) CrazyLogger.debug("Failed because the protocol does not equal .jar!");
ZipFile jar;
try {
CrazyLogger.debug("<#E0115F>Starting to extract files from <#11e092>" + input + " <#E0115F>directory in the jar.");
if (verbose) CrazyLogger.debug("<#E0115F>Starting to extract files from <#11e092>" + input + " <#E0115F>directory in the jar.");
jar = ((JarURLConnection) directory.openConnection()).getJarFile();
} catch (Exception e) {
@ -56,7 +55,7 @@ public class FileUtils {
if (entry.isDirectory()) {
if (exists) {
CrazyLogger.debug("<#E0115F>File already exists.");
if (verbose) CrazyLogger.debug("<#E0115F>File already exists.");
return;
}
@ -64,7 +63,7 @@ public class FileUtils {
try {
Files.createDirectories(outFile);
CrazyLogger.debug("<#E0115F>Directories have been created.");
if (verbose) CrazyLogger.debug("<#E0115F>Directories have been created.");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -11,6 +11,7 @@ import us.crazycrew.crazyauctions.configurations.ConfigSettings;
import us.crazycrew.crazyauctions.configurations.LocaleSettings;
import us.crazycrew.crazyauctions.configurations.PluginSettings;
import us.crazycrew.crazyauctions.configurations.migrations.PluginMigrationService;
import us.crazycrew.crazyauctions.utils.FileUtils;
import us.crazycrew.crazycore.CrazyLogger;
import us.crazycrew.crazycore.paper.PaperConsole;
import us.crazycrew.crazycore.paper.PaperCore;
@ -50,11 +51,6 @@ public class AuctionsStarter implements PluginBootstrap {
.withYamlFile(new File(context.getDataDirectory().toFile(), "config.yml"))
.configurationData(ConfigSettings.class)
.create();
locale = SettingsManagerBuilder
.withYamlFile(new File(context.getDataDirectory().toFile() + "/locale/", pluginConfig.getProperty(PluginSettings.LOCALE_FILE)))
.configurationData(LocaleSettings.class)
.create();
}
@Override
@ -74,6 +70,13 @@ public class AuctionsStarter implements PluginBootstrap {
// Add the logger manager.
LogManager.getLogManager().addLogger(CrazyLogger.getLogger());
FileUtils.extract("/locale", context.getDataDirectory(), false, getPluginConfig().getProperty(PluginSettings.VERBOSE_LOGGING));
locale = SettingsManagerBuilder
.withYamlFile(new File(context.getDataDirectory().toFile() + "/locale/", pluginConfig.getProperty(PluginSettings.LOCALE_FILE)))
.configurationData(LocaleSettings.class)
.create();
return new CrazyAuctions(this.paperCore);
}