Fix localweather
This commit is contained in:
parent
28c59a768a
commit
c10119233f
1 changed files with 6 additions and 7 deletions
|
@ -13,16 +13,15 @@ import eu.m724.realweather.weather.PlayerWeatherDirectory;
|
||||||
import eu.m724.wtapi.object.Weather;
|
import eu.m724.wtapi.object.Weather;
|
||||||
|
|
||||||
public class LocalWeatherCommand implements CommandExecutor {
|
public class LocalWeatherCommand implements CommandExecutor {
|
||||||
private PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
|
private final PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
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");
|
sender.sendMessage("You must be a player to use this command");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = (Player) sender;
|
|
||||||
Weather weather = playerWeatherDirectory.getWeather(player);
|
Weather weather = playerWeatherDirectory.getWeather(player);
|
||||||
long lastUpdate = playerWeatherDirectory.getLastUpdate(player);
|
long lastUpdate = playerWeatherDirectory.getLastUpdate(player);
|
||||||
|
|
||||||
|
@ -42,8 +41,8 @@ public class LocalWeatherCommand implements CommandExecutor {
|
||||||
if (weather.shower)
|
if (weather.shower)
|
||||||
player.sendMessage("Shower: yes");
|
player.sendMessage("Shower: yes");
|
||||||
|
|
||||||
player.sendMessage("Cloudiness: %d%%".formatted(weather.cloudiness * 100));
|
player.sendMessage("Cloudiness: %d%%".formatted((int) weather.cloudiness * 100));
|
||||||
player.sendMessage("Humidity: %d%%".formatted(weather.humidity * 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("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("Wind: %f (gust %f) m/s".formatted(weather.windSpeed, weather.windGust));
|
||||||
player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate)));
|
player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate)));
|
||||||
|
|
Loading…
Reference in a new issue