Package dev.chicoferreira.lifestealer
Class DurationUtils
java.lang.Object
dev.chicoferreira.lifestealer.DurationUtils
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
formatDurationTag
(@NotNull String key, @NotNull Duration duration) Creates a @{linkMiniMessage
} tag resolver that formats a duration using the given format usingDurationFormatUtils.formatDuration(long, String)
.static Duration
Parses a string into aDuration
.static void
-
Constructor Details
-
DurationUtils
public DurationUtils()
-
-
Method Details
-
setFormats
-
formatDurationTag
public static net.kyori.adventure.text.minimessage.tag.resolver.TagResolver formatDurationTag(@TagPattern @NotNull @NotNull String key, @NotNull @NotNull Duration duration) Creates a @{linkMiniMessage
} tag resolver that formats a duration using the given format usingDurationFormatUtils.formatDuration(long, String)
.- Parameters:
key
- The key of the tagduration
- The duration to format- Returns:
- A tag resolver that formats the duration using the given format
-
parse
Parses a string into aDuration
. The string should be formatted as a sequence of numbers followed by a unit. Supported units: s or S (seconds), m (minutes), h or H (hours), d or D (days), w or W (weeks), M (months), y or Y (years)Example: "1d 2h 3m 4s" returns a duration with 1 day, 2 hours, 3 minutes and 4 seconds
- Parameters:
string
- The string to parse- Returns:
- The parsed duration
- Throws:
IllegalArgumentException
- If the string is not in a valid format
-