config for date formatting

closes #20
This commit is contained in:
hyperdefined
2022-10-12 13:21:54 -04:00
parent 7639943fea
commit 2de2ae82a7
2 changed files with 20 additions and 1 deletions

View File

@@ -60,7 +60,7 @@ public final class ToolStats extends JavaPlugin {
// used for tracking new elytras
public final NamespacedKey newElytra = new NamespacedKey(this, "new");
public final SimpleDateFormat dateFormat = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
public SimpleDateFormat dateFormat;
public final DecimalFormat decimalFormat = new DecimalFormat("#,###.00", new DecimalFormatSymbols(Locale.getDefault()));
public final DecimalFormat commaFormat = new DecimalFormat("#,###", new DecimalFormatSymbols(Locale.getDefault()));
public BlocksMined blocksMined;
@@ -130,6 +130,20 @@ public final class ToolStats extends JavaPlugin {
if (config.getInt("config-version") != CONFIG_VERSION) {
logger.warning("Your config file is outdated! Please regenerate the config.");
}
String dateFormatConfig = config.getString("date-format");
if (dateFormatConfig != null) {
try {
dateFormat = new SimpleDateFormat(dateFormatConfig, Locale.getDefault());
} catch (IllegalArgumentException exception) {
logger.severe("date-format is NOT a valid format! Using default American English format.");
exception.printStackTrace();
dateFormat = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
}
} else {
logger.warning("date-format is missing from your config! Using default American English format.");
dateFormat = new SimpleDateFormat("M/dd/yyyy", Locale.ENGLISH);
}
}
public void checkForUpdates() {

View File

@@ -98,4 +98,9 @@ messages:
crafting: "&cCrafting items via shift clicking does not fully apply tags to each item. This is a limitation with the Bukkit API."
trading: "&cTrading items via shift clicking does not fully apply tags to each item. This is a limitation with the Bukkit API."
# Change the default formatting for dates.
# See: https://www.digitalocean.com/community/tutorials/java-simpledateformat-java-date-format
# Example: "dd/mm/yyyy"
date-format: "M/dd/yyyy"
config-version: 3