fix more errors

This commit is contained in:
Minecon724 2024-09-22 13:59:52 +02:00
parent c10119233f
commit 8f019b8cf5
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -1,6 +1,8 @@
package eu.m724.realweather.commands;
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import org.bukkit.command.Command;
@ -41,10 +43,10 @@ public class LocalWeatherCommand implements CommandExecutor {
if (weather.shower)
player.sendMessage("Shower: yes");
player.sendMessage("Cloudiness: %d%%".formatted((int) weather.cloudiness * 100));
player.sendMessage("Humidity: %d%%".formatted((int) weather.humidity * 100));
player.sendMessage("Temperature: %f (feels like %f) K".formatted(weather.temperature - 273.15, weather.temperatureApparent - 273.15));
player.sendMessage("Wind: %f (gust %f) m/s".formatted(weather.windSpeed, weather.windGust));
player.sendMessage("Cloudiness: %f%%".formatted(weather.cloudiness * 100));
player.sendMessage("Humidity: %f%%".formatted(weather.humidity * 100));
player.sendMessage("Temperature: %fC (feels like %fC)".formatted(weather.temperature - 273.15, weather.temperatureApparent - 273.15));
player.sendMessage("Wind: %fm/s (gust %fm/s) ".formatted(weather.windSpeed, weather.windGust));
player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate)));
} else {
@ -55,7 +57,7 @@ public class LocalWeatherCommand implements CommandExecutor {
}
private String formatTime(long timestamp) { // TODO move this
return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochSecond(timestamp));
return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.UTC));
}
}