Fix localweather
This commit is contained in:
parent
28c59a768a
commit
c10119233f
1 changed files with 6 additions and 7 deletions
|
@ -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)));
|
||||
|
|
Loading…
Reference in a new issue