Compare commits

..

No commits in common. "79d38bcbef469f1af084a29e27f297a0e088089c" and "4df951b7262753a1b02589d41d59e00f3e280359" have entirely different histories.

5 changed files with 19 additions and 35 deletions

View file

@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>eu.m724</groupId>
<artifactId>realweather</artifactId>
<version>0.9.4</version>
<version>0.9-alpha.4-SNAPSHOT</version>
<properties>
<maven.compiler.source>21</maven.compiler.source>
@ -14,7 +14,7 @@
<scm>
<developerConnection>scm:git:git@git.724.rocks:Minecon724/realweather.git</developerConnection>
<tag>realweather-0.9.4</tag>
<tag>HEAD</tag>
</scm>
<distributionManagement>
@ -49,7 +49,7 @@
<dependency>
<groupId>eu.m724</groupId>
<artifactId>wtapi</artifactId>
<version>0.7</version>
<version>0.6</version>
</dependency>
</dependencies>

View file

@ -24,7 +24,6 @@ import eu.m724.realweather.time.TimeMaster;
import eu.m724.realweather.updater.SignatureValidator;
import eu.m724.realweather.updater.Updater;
import eu.m724.realweather.updater.UpdaterConfig;
import eu.m724.realweather.weather.PlayerWeatherDirectory;
import eu.m724.realweather.weather.WeatherConfig;
import eu.m724.realweather.weather.WeatherMaster;
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
@ -95,7 +94,6 @@ public class RealWeatherPlugin extends JavaPlugin {
}
GlobalConstants.plugin = this;
GlobalConstants.playerWeatherDirectory = new PlayerWeatherDirectory();
DebugLogger.info("loading mapper", 1);
GlobalConstants.mapperConfig = MapperConfig.fromConfiguration(mapConfiguration);

View file

@ -8,7 +8,6 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import eu.m724.realweather.GlobalConstants;
import eu.m724.realweather.mapper.Mapper;
import eu.m724.realweather.weather.PlayerWeatherDirectory;
import eu.m724.wtapi.object.Coordinates;
import eu.m724.wtapi.object.Weather;
@ -17,8 +16,8 @@ import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
public class GeoCommand implements CommandExecutor {
private PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
private Mapper mapper = GlobalConstants.getMapper();
PlayerWeatherDirectory playerWeatherDirectory =
GlobalConstants.getPlayerWeatherDirectory();
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
@ -27,21 +26,22 @@ public class GeoCommand implements CommandExecutor {
if (args.length == 0) {
if (player != null) {
Location location = player.getLocation();
Coordinates coordinates = mapper.locationToCoordinates(location);
Weather weather = playerWeatherDirectory.getWeather(player);
String address = formatAddress(weather);
Coordinates coordinates = GlobalConstants.getMapper().locationToCoordinates(location);
BaseComponent[] component = new ComponentBuilder("\nGeolocation: ").color(ChatColor.GOLD)
.append("lat: %f, lon: %f\n".formatted(coordinates.latitude, coordinates.longitude)).color(ChatColor.AQUA)
.append("Position: ").color(ChatColor.GRAY)
.append("x: %f, z: %f\n".formatted(location.getX(), location.getZ())).color(ChatColor.DARK_AQUA)
.append("Address: ").color(ChatColor.GRAY)
.append(address + "\n").color(ChatColor.DARK_AQUA)
.append("x: %f, z: %f".formatted(location.getX(), location.getZ())).color(ChatColor.DARK_AQUA)
.create(); // TODO improve readability
player.spigot().sendMessage(component);
player.spigot().sendMessage(component);
Weather weather = playerWeatherDirectory.getWeather(player);
if (weather != null) {
component = new ComponentBuilder("You're in ").color(ChatColor.GRAY)
.append(weather.city + "\n").color(ChatColor.DARK_AQUA)
.create();
player.spigot().sendMessage(component);
}
} else {
sender.sendMessage("Add arguments to use this command in console");
}
@ -57,7 +57,7 @@ public class GeoCommand implements CommandExecutor {
}
Coordinates coordinates = new Coordinates(latitude, longitude);
Location location = mapper.coordinatesToLocation(player.getWorld(), coordinates);
Location location = GlobalConstants.getMapper().coordinatesToLocation(player.getWorld(), coordinates);
BaseComponent[] component = new ComponentBuilder("\nPosition: ").color(ChatColor.GOLD)
.append("x: %f, z: %f\n".formatted(location.getX(), location.getZ())).color(ChatColor.AQUA)
@ -72,7 +72,6 @@ public class GeoCommand implements CommandExecutor {
Location targetLoc =
location.getWorld().getHighestBlockAt(location).getLocation().add(0, 1, 0);
player.teleport(targetLoc);
player.sendMessage("Teleporting... The server will freeze for a second");
}
}
@ -81,18 +80,5 @@ public class GeoCommand implements CommandExecutor {
}
return true;
}
private String formatAddress(Weather weather) {
if (weather == null) return "Weather not retrieved yet";
Coordinates coordinates = weather.coordinates;
if (coordinates.country == null && coordinates.city == null)
return "Unknown";
else if (coordinates.city == null)
return "Country: " + coordinates.country;
else if (coordinates.country == null)
return coordinates.city;
return coordinates.city + ", " + coordinates.country;
}
}

View file

@ -69,9 +69,9 @@ public class Updater extends BukkitRunnable implements Listener {
DebugLogger.info("Unable to contact the update server! %d", 0, statusCode);
DebugLogger.info("As it's a server error, it's probably temporary and not a configuration issue, so proceeding.", 0);
} else {
DebugLogger.info("Update server returned unexpected status code: %d", 0, statusCode);
DebugLogger.info("Update server returned unexpected status code! %d", 0, statusCode);
if (plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
DebugLogger.info("Ignore as you're running a development snapshot.", 0);
DebugLogger.info("It looks like this is a development snapshot, possibly built from source. So actually this is expected.", 0);
} else {
DebugLogger.info("This is probably critical. RealWeather will continue without updater.", 0);
DebugLogger.info("Try restarting the server. If that doesn't help, contact support.", 0);

View file

@ -33,7 +33,7 @@ public class DynamicWeatherApplier extends BukkitRunnable {
if (player.hasPermission("realweather.actionbar")) {
String text = String.format("%f %f (%s) - %s",
weather.coordinates.latitude, weather.coordinates.longitude,
weather.coordinates.getAddress(), weather.description);
weather.city, weather.description);
BaseComponent component = TextComponent.fromLegacy(text);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, component);