Compare commits
2 commits
4df951b726
...
79d38bcbef
Author | SHA1 | Date | |
---|---|---|---|
79d38bcbef | |||
a6bd920d17 |
5 changed files with 35 additions and 19 deletions
6
pom.xml
6
pom.xml
|
@ -2,7 +2,7 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>realweather</artifactId>
|
||||
<version>0.9-alpha.4-SNAPSHOT</version>
|
||||
<version>0.9.4</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>HEAD</tag>
|
||||
<tag>realweather-0.9.4</tag>
|
||||
</scm>
|
||||
|
||||
<distributionManagement>
|
||||
|
@ -49,7 +49,7 @@
|
|||
<dependency>
|
||||
<groupId>eu.m724</groupId>
|
||||
<artifactId>wtapi</artifactId>
|
||||
<version>0.6</version>
|
||||
<version>0.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ 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;
|
||||
|
@ -94,6 +95,7 @@ public class RealWeatherPlugin extends JavaPlugin {
|
|||
}
|
||||
|
||||
GlobalConstants.plugin = this;
|
||||
GlobalConstants.playerWeatherDirectory = new PlayerWeatherDirectory();
|
||||
|
||||
DebugLogger.info("loading mapper", 1);
|
||||
GlobalConstants.mapperConfig = MapperConfig.fromConfiguration(mapConfiguration);
|
||||
|
|
|
@ -8,6 +8,7 @@ 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;
|
||||
|
@ -16,8 +17,8 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
|
||||
public class GeoCommand implements CommandExecutor {
|
||||
PlayerWeatherDirectory playerWeatherDirectory =
|
||||
GlobalConstants.getPlayerWeatherDirectory();
|
||||
private PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
|
||||
private Mapper mapper = GlobalConstants.getMapper();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
@ -26,22 +27,21 @@ public class GeoCommand implements CommandExecutor {
|
|||
if (args.length == 0) {
|
||||
if (player != null) {
|
||||
Location location = player.getLocation();
|
||||
Coordinates coordinates = GlobalConstants.getMapper().locationToCoordinates(location);
|
||||
Coordinates coordinates = mapper.locationToCoordinates(location);
|
||||
|
||||
Weather weather = playerWeatherDirectory.getWeather(player);
|
||||
String address = formatAddress(weather);
|
||||
|
||||
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".formatted(location.getX(), location.getZ())).color(ChatColor.DARK_AQUA)
|
||||
.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)
|
||||
.create(); // TODO improve readability
|
||||
|
||||
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 = GlobalConstants.getMapper().coordinatesToLocation(player.getWorld(), coordinates);
|
||||
Location location = mapper.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,6 +72,7 @@ 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,4 +82,17 @@ 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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("It looks like this is a development snapshot, possibly built from source. So actually this is expected.", 0);
|
||||
DebugLogger.info("Ignore as you're running a development snapshot.", 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);
|
||||
|
|
|
@ -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.city, weather.description);
|
||||
weather.coordinates.getAddress(), weather.description);
|
||||
BaseComponent component = TextComponent.fromLegacy(text);
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, component);
|
||||
|
||||
|
|
Loading…
Reference in a new issue