Fix localweather

This commit is contained in:
Minecon724 2024-09-22 13:49:27 +02:00
parent 28c59a768a
commit c10119233f
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -13,16 +13,15 @@ import eu.m724.realweather.weather.PlayerWeatherDirectory;
import eu.m724.wtapi.object.Weather;
public class LocalWeatherCommand implements CommandExecutor {
private PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
private final PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
if (!(sender instanceof Player player)) {
sender.sendMessage("You must be a player to use this command");
return true;
}
Player player = (Player) sender;
Weather weather = playerWeatherDirectory.getWeather(player);
long lastUpdate = playerWeatherDirectory.getLastUpdate(player);
@ -42,8 +41,8 @@ public class LocalWeatherCommand implements CommandExecutor {
if (weather.shower)
player.sendMessage("Shower: yes");
player.sendMessage("Cloudiness: %d%%".formatted(weather.cloudiness * 100));
player.sendMessage("Humidity: %d%%".formatted(weather.humidity * 100));
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("Last update: %s UTC".formatted(formatTime(lastUpdate)));