Skip to content

Commit 6c74d97

Browse files
Don't waste time on formatting the string twice
1 parent 9e94ffb commit 6c74d97

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

shared/src/main/java/net/pistonmaster/pistonqueue/shared/SharedChatUtils.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ private SharedChatUtils() {
2626
}
2727

2828
public static String formatDuration(String str, Duration duration, int position) {
29-
String format = String.format("%dh %dm", duration.toHours(), duration.toMinutes() % 60);
30-
31-
if (duration.toHours() == 0)
32-
format = String.format("%dm", duration.toMinutes() == 0 ? 1 : duration.toMinutes());
29+
String format = duration.toHours() == 0 ?
30+
String.format("%dm", duration.toMinutes() == 0 ? 1 : duration.toMinutes()) :
31+
String.format("%dh %dm", duration.toHours(), duration.toMinutes() % 60);
3332

3433
return str.replace("%position%", String.valueOf(position)).replace("%wait%", format);
3534
}

0 commit comments

Comments
 (0)