diff --git a/pom.xml.releaseBackup b/pom.xml.releaseBackup
deleted file mode 100644
index f44a5c3..0000000
--- a/pom.xml.releaseBackup
+++ /dev/null
@@ -1,136 +0,0 @@
-
- 4.0.0
- eu.m724
- realweather
- 0.9.5-SNAPSHOT
-
-
- 21
- 21
- ${project.basedir}/testkeystore
- testkey
- 123456
-
-
-
- scm:git:git@git.724.rocks:Minecon724/realweather.git
- HEAD
-
-
-
-
- 724rocks
- https://git.724.rocks/api/packages/Minecon724/maven
-
-
- 724rocks
- https://git.724.rocks/api/packages/Minecon724/maven
-
-
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
-
- 724rocks
- https://git.724.rocks/api/packages/Minecon724/maven
-
-
-
-
-
- org.spigotmc
- spigot-api
- 1.21-R0.1-SNAPSHOT
- provided
-
-
- eu.m724
- wtapi
- 0.7
-
-
- eu.m724
- jarupdater
- 0.1.0
-
-
-
-
-
-
- src/main/resources
- true
-
-
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 3.0.1
-
- true
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.6.0
-
-
- package
-
- shade
-
-
-
-
- eu.m724:wtapi
- eu.m724:jarupdater
-
-
-
-
-
- eu.m724:*
-
- META-INF/MANIFEST.MF
-
-
-
- true
- false
-
-
-
-
-
- org.apache.maven.plugins
- maven-jarsigner-plugin
- 3.0.0
-
-
- sign
-
- sign
-
-
-
- verify
-
- verify
-
-
-
-
- ${jarsigner.keystore}
- ${jarsigner.alias}
- ${jarsigner.storepass}
-
-
-
-
-
-
\ No newline at end of file
diff --git a/release.properties b/release.properties
deleted file mode 100644
index 1bdc1e2..0000000
--- a/release.properties
+++ /dev/null
@@ -1,24 +0,0 @@
-#release configuration
-#Wed Jun 26 15:17:02 CEST 2024
-completedPhase=end-release
-exec.pomFileName=pom.xml
-exec.snapshotReleasePluginAllowed=false
-pinExternals=false
-preparationGoals=clean verify
-project.dev.eu.m724\:realweather=0.9.6-SNAPSHOT
-project.rel.eu.m724\:realweather=0.9.5
-project.scm.eu.m724\:realweather.developerConnection=scm\:git\:git@git.724.rocks\:Minecon724/realweather.git
-project.scm.eu.m724\:realweather.tag=HEAD
-projectVersionPolicyConfig=${projectVersionPolicyConfig}\n
-projectVersionPolicyId=default
-pushChanges=true
-releaseStrategyId=default
-remoteTagging=true
-scm.branchCommitComment=@{prefix} prepare branch @{releaseLabel}
-scm.commentPrefix=[maven-release-plugin]
-scm.developmentCommitComment=@{prefix} prepare for next development iteration
-scm.releaseCommitComment=@{prefix} prepare release @{releaseLabel}
-scm.rollbackCommitComment=@{prefix} rollback the release of @{releaseLabel}
-scm.tag=realweather-0.9.5
-scm.tagNameFormat=@{project.artifactId}-@{project.version}
-scm.url=scm\:git\:git@git.724.rocks\:Minecon724/realweather.git
diff --git a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java
index d5f8ba4..5014f0b 100644
--- a/src/main/java/eu/m724/realweather/RealWeatherPlugin.java
+++ b/src/main/java/eu/m724/realweather/RealWeatherPlugin.java
@@ -14,6 +14,7 @@ import com.google.common.base.Charsets;
import eu.m724.realweather.commands.AdminCommand;
import eu.m724.realweather.commands.GeoCommand;
import eu.m724.realweather.commands.LocalTimeCommand;
+import eu.m724.realweather.commands.LocalWeatherCommand;
import eu.m724.realweather.exception.UserError;
import eu.m724.realweather.mapper.Mapper;
import eu.m724.realweather.mapper.MapperConfig;
@@ -134,6 +135,9 @@ public class RealWeatherPlugin extends JavaPlugin {
if (GlobalConstants.timeConfig.enabled)
getCommand("localtime").setExecutor(new LocalTimeCommand());
+ if (GlobalConstants.weatherConfig.enabled)
+ getCommand("localweather").setExecutor(new LocalWeatherCommand());
+
DebugLogger.info("ended loading", 1);
}
diff --git a/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java
new file mode 100644
index 0000000..1992bc9
--- /dev/null
+++ b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java
@@ -0,0 +1,62 @@
+package eu.m724.realweather.commands;
+
+import java.time.Instant;
+import java.time.format.DateTimeFormatter;
+
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+import org.bukkit.entity.Player;
+
+import eu.m724.realweather.GlobalConstants;
+import eu.m724.realweather.weather.PlayerWeatherDirectory;
+import eu.m724.wtapi.object.Weather;
+
+public class LocalWeatherCommand implements CommandExecutor {
+ private PlayerWeatherDirectory playerWeatherDirectory = GlobalConstants.getPlayerWeatherDirectory();
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage("You must be a player to use this command");
+ return true;
+ }
+
+ Player player = (Player) sender;
+ Weather weather = playerWeatherDirectory.getWeather(player);
+ long lastUpdate = playerWeatherDirectory.getLastUpdate(player);
+
+ if (weather != null) {
+ player.sendMessage(weather.description);
+
+ if (weather.rainSeverity != null)
+ player.sendMessage("Rain: %s".formatted(weather.rainSeverity.toString()));
+ if (weather.drizzleSeverity != null)
+ player.sendMessage("Drizzle: %s".formatted(weather.drizzleSeverity.toString()));
+ if (weather.sleetSeverity != null)
+ player.sendMessage("Sleet: %s".formatted(weather.sleetSeverity.toString()));
+ if (weather.snowSeverity != null)
+ player.sendMessage("Snow: %s".formatted(weather.snowSeverity.toString()));
+ if (weather.thunderstormSeverity != null)
+ player.sendMessage("Thunderstorm: %s".formatted(weather.thunderstormSeverity.toString()));
+ 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("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)));
+
+ } else {
+ player.sendMessage("No weather for you");
+ }
+
+ return true;
+ }
+
+ private String formatTime(long timestamp) { // TODO move this
+ return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochSecond(timestamp));
+ }
+
+}
diff --git a/src/main/java/eu/m724/realweather/weather/AsyncWeatherRetriever.java b/src/main/java/eu/m724/realweather/weather/AsyncWeatherRetriever.java
index 4f9de91..3e489c3 100644
--- a/src/main/java/eu/m724/realweather/weather/AsyncWeatherRetriever.java
+++ b/src/main/java/eu/m724/realweather/weather/AsyncWeatherRetriever.java
@@ -37,6 +37,7 @@ public class AsyncWeatherRetriever extends BukkitRunnable implements Listener {
@Override
public void run() {
DebugLogger.info("Weather retrieval", 3);
+ long now = System.currentTimeMillis();
long delay = 6000;
if (dynamic) {
@@ -65,7 +66,7 @@ public class AsyncWeatherRetriever extends BukkitRunnable implements Listener {
Player player = players.get(i);
Weather weather = weathers[i];
- playerWeatherDirectory.weathers.put(player, weather);
+ playerWeatherDirectory.put(player, weather, now);
AsyncWeatherUpdateEvent event =
new AsyncWeatherUpdateEvent(player, weather);
@@ -116,7 +117,7 @@ public class AsyncWeatherRetriever extends BukkitRunnable implements Listener {
DebugLogger.info("A player joined so I requested weather", 3);
weatherFuture.thenAccept(weather -> {
- playerWeatherDirectory.weathers.put(player, weather);
+ playerWeatherDirectory.put(player, weather, System.currentTimeMillis());
AsyncWeatherUpdateEvent weatherEvent =
new AsyncWeatherUpdateEvent(player, weather);
diff --git a/src/main/java/eu/m724/realweather/weather/DynamicWeatherApplier.java b/src/main/java/eu/m724/realweather/weather/DynamicWeatherApplier.java
deleted file mode 100644
index 3aabeb4..0000000
--- a/src/main/java/eu/m724/realweather/weather/DynamicWeatherApplier.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package eu.m724.realweather.weather;
-
-import java.util.List;
-
-import org.bukkit.WeatherType;
-import org.bukkit.entity.Player;
-import org.bukkit.scheduler.BukkitRunnable;
-
-import eu.m724.realweather.DebugLogger;
-import eu.m724.wtapi.object.Weather;
-import net.md_5.bungee.api.ChatMessageType;
-import net.md_5.bungee.api.chat.BaseComponent;
-import net.md_5.bungee.api.chat.TextComponent;
-
-// TODO this class is currently unused and it will probably be removed or replaced
-public class DynamicWeatherApplier extends BukkitRunnable {
- private List players;
- private Weather[] weathers;
-
- public DynamicWeatherApplier(List players, Weather[] weathers) {
- this.players = players;
- this.weathers = weathers;
- }
-
- @Override
- public void run() {
- DebugLogger.info("applying weather for %d players", 2, players.size());
-
- for (int i=0; i weathers = new HashMap<>();
+ HashMap lastUpdates = new HashMap<>();
+
+ void put(Player player, Weather weather, Long lastUpdate) {
+ weathers.put(player, weather);
+ lastUpdates.put(player, lastUpdate);
+ }
public Weather getWeather(Player player) {
return weathers.get(player); // TODO concurrent exception?
}
+
+ public Long getLastUpdate(Player player) {
+ return lastUpdates.get(player); // TODO concurrent exception?
+ }
}
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 53bbe08..928f8e8 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -25,6 +25,10 @@ commands:
description: Get real time in current location
permission: realweather.command.localtime
permission-message: You do not have permission to use this command.
+ localweather:
+ description: Get weather in current location
+ permission: realweather.command.localweather
+ permission-message: You do not have permission to use this command.
permissions:
# Commands
@@ -42,6 +46,9 @@ permissions:
realweather.command.localtime:
description: Allows /localtime
default: true
+ realweather.command.localweather:
+ description: Allows /localweather
+ default: true
# Engine