Package me.croabeast.common.time
Class TimeValues
java.lang.Object
me.croabeast.common.time.TimeValues
Represents a collection of string formats for different time units.
TimeValues holds configurable formatting strings for seconds, minutes, hours,
days, weeks, months, and years. It is designed to support multiple languages and custom formatting.
The class includes pre-defined instances such as DEFAULT_KEYS and SPANISH_KEYS.
Once an instance is "locked" (i.e. modification is disabled), its values cannot be changed.
The formatting strings are used in conjunction with TimeFormatter to produce human-readable
representations of time durations.
Example usage:
// Using default keys:
TimeValues defaults = TimeValues.DEFAULT_KEYS;
// Customizing for Spanish:
TimeValues spanish = TimeValues.SPANISH_KEYS;
// Load from configuration:
ConfigurationSection section = ...;
TimeValues configValues = TimeValues.fromSection(section);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TimeValuesDefault time unit keys in English.static final TimeValuesPredefined time unit keys for Spanish language. -
Method Summary
Modifier and TypeMethodDescriptionstatic TimeValuescreate()Creates a new modifiable instance ofTimeValues.static TimeValuesfromSection(org.bukkit.configuration.ConfigurationSection section) Creates aTimeValuesinstance from a configuration section.setDaysFormat(String daysFormat) Sets the format string for days.setHoursFormat(String hoursFormat) Sets the format string for hours.setMinutesFormat(String minutesFormat) Sets the format string for minutes.setMonthsFormat(String monthsFormat) Sets the format string for months.setSecondsFormat(String secondsFormat) Sets the format string for seconds.setSplitter(String splitter) Sets the splitter string used between time unit segments.setWeeksFormat(String weeksFormat) Sets the format string for weeks.setYearsFormat(String yearsFormat) Sets the format string for years.
-
Field Details
-
DEFAULT_KEYS
Default time unit keys in English. -
SPANISH_KEYS
Predefined time unit keys for Spanish language.
-
-
Method Details
-
setSplitter
Sets the splitter string used between time unit segments.- Parameters:
splitter- the new splitter string (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setSecondsFormat
Sets the format string for seconds.- Parameters:
secondsFormat- the format string for seconds (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setMinutesFormat
Sets the format string for minutes.- Parameters:
minutesFormat- the format string for minutes (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setHoursFormat
Sets the format string for hours.- Parameters:
hoursFormat- the format string for hours (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setDaysFormat
Sets the format string for days.- Parameters:
daysFormat- the format string for days (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setWeeksFormat
Sets the format string for weeks.- Parameters:
weeksFormat- the format string for weeks (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setMonthsFormat
Sets the format string for months.- Parameters:
monthsFormat- the format string for months (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
setYearsFormat
Sets the format string for years.- Parameters:
yearsFormat- the format string for years (must not be blank)- Returns:
- this
TimeValuesinstance for chaining
-
create
Creates a new modifiable instance ofTimeValues.- Returns:
- a new
TimeValuesinstance with default formats
-
fromSection
Creates aTimeValuesinstance from a configuration section.The configuration should contain keys such as "splitter", "seconds", "minutes", "hours", "days", "weeks", "months", and "years". If a key is missing or invalid, the corresponding default value is retained.
- Parameters:
section- the configuration section containing time format settings- Returns:
- a new
TimeValuesinstance loaded from the configuration - Throws:
NullPointerException- if the configuration section isnull
-