Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class DurationTag implements ObjectTag {
// Durations are a unified and convenient way to get a 'unit of time' throughout Denizen.
// Many commands and features that require a duration can be satisfied by specifying a number and unit of time, especially command arguments that are prefixed 'duration:', etc.
// The unit of time can be specified by using one of the following:
// t=ticks (0.05 seconds), s=seconds, m=minutes (60 seconds), h=hours (60 minutes), d=days (24 hours), w=weeks (7 days), y=years (365 days).
// ms=milliseconds (0.001 seconds), t=ticks (0.05 seconds), s=seconds, m=minutes (60 seconds), h=hours (60 minutes), d=days (24 hours), w=weeks (7 days), y=years (365 days).
// Not using a unit will imply seconds.
// Examples: 10s, 50m, 1d, 20.
//
Expand Down Expand Up @@ -93,7 +93,7 @@ public static DurationTag valueOf(String string, TagContext context) {
}
}
}
String numericString = Character.isDigit(string.charAt(string.length() - 1)) ? string : string.substring(0, string.length() - 1);
String numericString = Character.isDigit(string.charAt(string.length() - 1)) ? string : string.substring(0, string.endsWith("ms") ? string.length() - 2 : string.length() - 1);
// Standard DurationTag. Check the type and create new DurationTag object accordingly.
try {
double numVal = Double.parseDouble(numericString);
Expand All @@ -112,6 +112,9 @@ else if (string.endsWith("h")) {
else if (string.endsWith("m")) {
return new DurationTag(numVal * 60);
}
else if (string.endsWith("ms")) {
return new DurationTag(numVal * 0.001);
}
else if (string.endsWith("s")) {
// seconds
return new DurationTag(numVal);
Expand Down