mirror of
https://github.com/itHotL/PlayerStats.git
synced 2024-11-26 12:36:16 +01:00
Fixed bug where time-unit sometimes has too many spaces once again (#81)
This commit is contained in:
parent
1d05a6d0af
commit
52ad16f40b
@ -158,7 +158,6 @@ public class ComponentFactory {
|
||||
.args(subStat));
|
||||
}
|
||||
|
||||
//TODO Add hoverComponent with full number
|
||||
public TextComponent.Builder statNumberBuilder(String prettyNumber, Target selection) {
|
||||
return getComponentBuilder(prettyNumber,
|
||||
getColorFromString(config.getStatNumberDecoration(selection, false)),
|
||||
|
@ -116,7 +116,7 @@ public class MessageWriter {
|
||||
.append(space())
|
||||
.append(getStatNameComponent(request))
|
||||
.append(getStatUnitComponent(request.getStatistic(), request.getSelection()))
|
||||
.build();
|
||||
.build(); //space is provided by statUnitComponent
|
||||
}
|
||||
|
||||
public TextComponent formatTopStats(@NotNull LinkedHashMap<String, Integer> topStats, @NotNull StatRequest request) {
|
||||
@ -125,7 +125,7 @@ public class MessageWriter {
|
||||
.append(componentFactory.pluginPrefixComponent(request.isBukkitConsoleSender())).append(space())
|
||||
.append(componentFactory.titleComponent(config.getTopStatsTitle(), Target.TOP)).append(space())
|
||||
.append(componentFactory.titleNumberComponent(topStats.size())).append(space())
|
||||
.append(getStatNameComponent(request))
|
||||
.append(getStatNameComponent(request)) //space is provided by statUnitComponent
|
||||
.append(getStatUnitComponent(request.getStatistic(), request.getSelection()));
|
||||
|
||||
ArrayList<Unit> timeUnits = null;
|
||||
@ -227,7 +227,7 @@ public class MessageWriter {
|
||||
Unit hoverUnit = type == Unit.Type.DISTANCE ? Unit.fromString(config.getDistanceUnit(true)) :
|
||||
Unit.fromString(config.getDamageUnit(true));
|
||||
String prettyHoverNumber = formatter.format(statNumber, hoverUnit);
|
||||
MyLogger.logMsg("mainNumber: " + prettyNumber + "\n" + "hoverNumber: " + prettyHoverNumber, DebugLevel.HIGH);
|
||||
MyLogger.logMsg("mainNumber: " + prettyNumber + ", hoverNumber: " + prettyHoverNumber, DebugLevel.HIGH);
|
||||
if (config.useTranslatableComponents()) {
|
||||
String unitKey = languageKeyHandler.getUnitKey(hoverUnit);
|
||||
if (unitKey == null) {
|
||||
|
@ -85,34 +85,52 @@ public class NumberFormatter {
|
||||
if (isInRange(max, min, 86400) && leftover >= 86400) {
|
||||
double days = Math.floor(leftover / 86400);
|
||||
leftover = leftover % (86400);
|
||||
if (smallUnit == Unit.DAY && leftover >= 43200) {
|
||||
return output.append(format.format(days+1))
|
||||
if (smallUnit == Unit.DAY) {
|
||||
if (leftover >= 43200) {
|
||||
days++;
|
||||
}
|
||||
return output.append(format.format(days))
|
||||
.append("d").toString();
|
||||
}
|
||||
output.append(format.format(days))
|
||||
.append("d");
|
||||
}
|
||||
if (isInRange(max, min, 3600) && leftover >= 3600) {
|
||||
if (output.toString().contains("d")) {
|
||||
output.append(" ");
|
||||
}
|
||||
double hours = Math.floor(leftover / 60 / 60);
|
||||
leftover = leftover % (60 * 60);
|
||||
if (smallUnit == Unit.HOUR && leftover >= 1800) {
|
||||
return output.append(format.format(hours+1))
|
||||
if (smallUnit == Unit.HOUR) {
|
||||
if (leftover >= 1800) {
|
||||
hours++;
|
||||
}
|
||||
return output.append(format.format(hours))
|
||||
.append("h").toString();
|
||||
}
|
||||
output.append(format.format(hours))
|
||||
.append("h");
|
||||
}
|
||||
if (isInRange(max, min, 60) && leftover >= 60) {
|
||||
if (output.toString().contains("h")) {
|
||||
output.append(" ");
|
||||
}
|
||||
double minutes = Math.floor(leftover / 60);
|
||||
leftover = leftover % 60;
|
||||
if (smallUnit == Unit.MINUTE && leftover >= 30) {
|
||||
return output.append(format.format(minutes+1))
|
||||
if (smallUnit == Unit.MINUTE) {
|
||||
if (leftover >= 30) {
|
||||
minutes++;
|
||||
}
|
||||
return output.append(format.format(minutes))
|
||||
.append("m").toString();
|
||||
}
|
||||
output.append(format.format(minutes))
|
||||
.append("m");
|
||||
}
|
||||
if (isInRange(max, min, 1) && leftover > 0) {
|
||||
if (output.toString().contains("m")) {
|
||||
output.append(" ");
|
||||
}
|
||||
double seconds = Math.ceil(leftover);
|
||||
output.append(format.format(seconds))
|
||||
.append("s");
|
||||
|
Loading…
Reference in New Issue
Block a user