Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.

Commit

Permalink
Fix time parsing errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Mar 12, 2023
1 parent ec81a13 commit 0a365ef
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public static void handleInscriptionTooltip(EmbedBuilder builder, ItemStack item
appendDescription(Math.round(compoundTag.getFloat("completion") * 100.0F) + "%").
appendDescription("\n");
builder.appendDescription("**Time:** ").
appendDescription(UIHelper.formatTimeString(compoundTag.getInt("time"))).
appendDescription(formatTimeString(compoundTag.getInt("time"))).
appendDescription("\n");
builder.appendDescription("**Instability:** ").
appendDescription(Math.round(compoundTag.getInt("instability") * 100.0F) + "%").
Expand Down Expand Up @@ -955,6 +955,21 @@ private static void parseModifiers(EmbedBuilder builder, CrystalModifiers modifi
}


/**
* Time parser
* @param remainingTicks how many ticks remaining
* @return remaining ticks parsed as string.
*/
private static String formatTimeString(int remainingTicks)
{
long seconds = remainingTicks / 20 % 60;
long minutes = remainingTicks / 20 / 60 % 60;
long hours = remainingTicks / 20 / 60 / 60;
return hours > 0L ? String.format("%02d:%02d:%02d", hours, minutes, seconds) :
String.format("%02d:%02d", minutes, seconds);
}


// ---------------------------------------------------------------------
// Section: Variables
// ---------------------------------------------------------------------
Expand Down

0 comments on commit 0a365ef

Please sign in to comment.