From c10119233f27383cb57b30ceadeacda76e2f3d44 Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sun, 22 Sep 2024 13:49:27 +0200 Subject: [PATCH] Fix localweather --- .../realweather/commands/LocalWeatherCommand.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java index 1992bc9..d2aa19e 100644 --- a/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java +++ b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java @@ -13,17 +13,16 @@ 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); + + Weather weather = playerWeatherDirectory.getWeather(player); long lastUpdate = playerWeatherDirectory.getLastUpdate(player); if (weather != null) { @@ -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)));