Compare commits

...

10 commits

Author SHA1 Message Date
7cdec756b8
[maven-release-plugin] rollback the release of realweather-1.0.0-alpha.1 2024-09-22 14:00:58 +02:00
4239aba5b4
[maven-release-plugin] prepare release realweather-1.0.0-alpha.1 2024-09-22 14:00:52 +02:00
8f019b8cf5
fix more errors 2024-09-22 13:59:52 +02:00
c10119233f
Fix localweather 2024-09-22 13:49:27 +02:00
28c59a768a
Improve English in .ymls
...
2024-09-22 13:47:51 +02:00
c645d56085
Make configs created automatically
They weren't???
2024-09-22 13:46:49 +02:00
88df6c5781
Improve English
Commits like this one are seriously embarrassing
2024-09-22 13:26:51 +02:00
35f8c5f882
Suggestion for future me 2024-09-22 13:23:31 +02:00
7eac4a399f
Reorganize POM 2024-09-22 13:06:15 +02:00
664eca4f3b
Even more IDEA files
Why can't it add everything at once
2024-09-22 13:06:05 +02:00
12 changed files with 90 additions and 59 deletions

8
.idea/modules.xml Normal file
View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/realweather.iml" filepath="$PROJECT_DIR$/realweather.iml" />
</modules>
</component>
</project>

41
pom.xml
View file

@ -11,23 +11,7 @@
<jarsigner.alias>testkey</jarsigner.alias> <jarsigner.alias>testkey</jarsigner.alias>
<jarsigner.storepass>123456</jarsigner.storepass> <jarsigner.storepass>123456</jarsigner.storepass>
</properties> </properties>
<scm>
<developerConnection>scm:git:git@git.m724.eu:Minecon724/realweather.git</developerConnection>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<repository>
<id>m724</id>
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
</repository>
<snapshotRepository>
<id>m724</id>
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
</snapshotRepository>
</distributionManagement>
<repositories> <repositories>
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
@ -43,7 +27,7 @@
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version> <version>1.21.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -69,7 +53,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId> <artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version> <version>3.1.1</version>
<configuration> <configuration>
<allowTimestampedSnapshots>true</allowTimestampedSnapshots> <allowTimestampedSnapshots>true</allowTimestampedSnapshots>
</configuration> </configuration>
@ -109,7 +93,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jarsigner-plugin</artifactId> <artifactId>maven-jarsigner-plugin</artifactId>
<version>3.0.0</version> <version>3.1.0</version>
<executions> <executions>
<execution> <execution>
<id>sign</id> <id>sign</id>
@ -132,5 +116,20 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<distributionManagement>
<repository>
<id>m724</id>
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
</repository>
<snapshotRepository>
<id>m724</id>
<url>https://git.m724.eu/api/packages/Minecon724/maven</url>
</snapshotRepository>
</distributionManagement>
<scm>
<developerConnection>scm:git:git@git.m724.eu:Minecon724/realweather.git</developerConnection>
<tag>HEAD</tag>
</scm>
</project> </project>

13
realweather.iml Normal file
View file

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
</module>

View file

@ -11,6 +11,7 @@ import eu.m724.realweather.updater.UpdaterConfig;
import eu.m724.realweather.weather.PlayerWeatherDirectory; import eu.m724.realweather.weather.PlayerWeatherDirectory;
import eu.m724.realweather.weather.WeatherConfig; import eu.m724.realweather.weather.WeatherConfig;
// TODO perhaps replace with a singleton
public class GlobalConstants { public class GlobalConstants {
static WeatherConfig weatherConfig; static WeatherConfig weatherConfig;
static TimeConfig timeConfig; static TimeConfig timeConfig;

View file

@ -51,15 +51,8 @@ public class RealWeatherPlugin extends JavaPlugin {
thunderConfiguration, timeConfiguration; thunderConfiguration, timeConfiguration;
DebugLogger.info("loading configurations", 1); DebugLogger.info("loading configurations", 1);
boolean firstRun = !new File(dataFolder, "config.yml").exists();
if (!new File(dataFolder, "config.yml").exists()) {
logger.info("This is the first run of this plugin.");
logger.info("Please shutdown the server and input your API keys and settings");
getServer().getPluginManager().disablePlugin(this);
return;
}
try { try {
configuration = getConfig("config.yml"); configuration = getConfig("config.yml");
mapConfiguration = getConfig("map.yml"); mapConfiguration = getConfig("map.yml");
@ -73,12 +66,20 @@ public class RealWeatherPlugin extends JavaPlugin {
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }
if (firstRun) {
logger.warning("This is the first time running this plugin.");
logger.warning("Please shut down the server, review the config files, and enter your API keys.");
getServer().getPluginManager().disablePlugin(this);
return;
}
DebugLogger.baseLogger = logger; DebugLogger.baseLogger = logger;
DebugLogger.debugLevel = configuration.getInt("debug"); DebugLogger.debugLevel = configuration.getInt("debug");
if (!configuration.getBoolean("enabled")) { if (!configuration.getBoolean("enabled")) {
logger.info("plugin disabled by admin"); logger.info("Plugin disabled by configuration!");
getServer().getPluginManager().disablePlugin(this); getServer().getPluginManager().disablePlugin(this);
return; return;
} }

View file

@ -1,6 +1,8 @@
package eu.m724.realweather.commands; package eu.m724.realweather.commands;
import java.time.Instant; import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -13,17 +15,16 @@ 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);
if (weather != null) { if (weather != null) {
@ -42,10 +43,10 @@ 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: %f%%".formatted(weather.cloudiness * 100));
player.sendMessage("Humidity: %d%%".formatted(weather.humidity * 100)); player.sendMessage("Humidity: %f%%".formatted(weather.humidity * 100));
player.sendMessage("Temperature: %f (feels like %f) K".formatted(weather.temperature - 273.15, weather.temperatureApparent - 273.15)); player.sendMessage("Temperature: %fC (feels like %fC)".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: %fm/s (gust %fm/s) ".formatted(weather.windSpeed, weather.windGust));
player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate))); player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate)));
} else { } else {
@ -56,7 +57,7 @@ public class LocalWeatherCommand implements CommandExecutor {
} }
private String formatTime(long timestamp) { // TODO move this private String formatTime(long timestamp) { // TODO move this
return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochSecond(timestamp)); return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.UTC));
} }
} }

View file

@ -9,14 +9,15 @@ updater:
# Notify players and console about plugin updates # Notify players and console about plugin updates
# This also controls automatic checking # This also controls automatic checking
# You can still update with /rwadmin update # You can still update with /rwadmin update
# Revelant permission node: realweather.update.notify # Relevant permission node: realweather.update.notify
notify: true notify: true
# stable for stable releases # stable for stable releases
# testing for latest builds (untested hence the name) # testing for latest builds (untested hence the name)
# As there's no release yet, stable will just error
channel: testing channel: testing
# 0 - no debug # 0 - no debug
# 1 - debug loading modules # 1 - debug loading modules
# 2 - also debug processing conditions # 2 - also debug processing conditions
# 3 - also log tasks running, this will spam # 3 - also log tasks running, this will spam
debug: 3 debug: 0

View file

@ -8,16 +8,16 @@ worlds:
- world - world
dimensions: dimensions:
# blocks per 1 deg, can't be decimal # Blocks per 1 deg, can't be decimal
# the default (111000) assumes 1 block = 1 meter # The default (111000) assumes 1 block = 1 meter
latitude: 111000 latitude: 111000
longitude: 111000 longitude: 111000
# if you want the globe to cover the whole world use: # If you want the globe to cover the whole (Minecraft) world use:
# latitude: 333333 # latitude: 333333
# longitude: 166666 # longitude: 166666
# if you use `static` mode # For `static` mode
point: point:
latitude: 0 latitude: 0
longitude: 0 longitude: 0

View file

@ -4,11 +4,11 @@
enabled: false enabled: false
# currently only blitzortung # Currently only blitzortung
provider: blitzortung provider: blitzortung
# how often should we poll for updates and spawn lightning # How often should we poll for updates and spawn lightning
# this is a synchronous task # This is a synchronous task
# if you put it too low you'll have constant lag # If you put it too low you'll have constant lag,
# but if you put it too high it will process a lot of data at once so you'll have lag spikes # But if you put it too high it will process a lot of data at once so you'll have lag spikes
refresh: 100 # ticks refresh: 100 # ticks

View file

@ -2,16 +2,19 @@
### TIME SETTINGS ### ### TIME SETTINGS ###
############################ ############################
# warning: this removes sleep # Warning: this removes sleep
# No, it's not a bug. It would de-synchronize, and can you skip time IRL?
# Can you believe that I actually used to consider this a bug?
enabled: false enabled: false
# How this plugin affects your world: # How this plugin affects your world:
# - static (false): time is the same across the world # - static (false): time is the same across the world
# - dynamic (true): static + local time for each player, however it's only cosmetical so it will not match mobs spawning etc # - dynamic (true): static + local time for each player, however it's only cosmetic so it will not match mobs spawning etc
# settings for both are in map.yml # Settings for both are in map.yml
dynamic: true dynamic: true
# x in game day cycles in 1 irl day cycle # x in game day cycles in 1 irl day cycle
# time will no longer be in sync # Time will no longer be in sync
# can be decimal # Can be decimal
scale: 1.0 scale: 1.0

View file

@ -2,6 +2,10 @@
### WEATHER SETTINGS ### ### WEATHER SETTINGS ###
############################ ############################
# Weather in Minecraft is limited, it can only rain or not rain, thunder or not thunder.
# In real life, there is a scale, and many more weather conditions in general, like blizzard.
# This plugin tries hard to do something about it, but it's not perfect, because it's just impossible.
enabled: false enabled: false
# Currently only OpenWeatherMap # Currently only OpenWeatherMap
@ -11,6 +15,6 @@ apiKey: REPLACE ME
# How this plugin affects your world: # How this plugin affects your world:
# - static (false): weather is the same across the world # - static (false): weather is the same across the world
# - dynamic (true): weather is per player, however it's only cosmetical so it will not match mobs spawning etc # - dynamic (true): weather is per player, however it's only cosmetic so it will not match mobs spawning etc
# settings for both are in map.yml # settings for both are in map.yml
dynamic: true dynamic: true

View file

@ -2,7 +2,7 @@ name: RealWeather
version: ${project.version} version: ${project.version}
author: Minecon724 author: Minecon724
website: https://forum.m724.eu/topic/3/realweather-1-0 website: https://www.spigotmc.org/resources/realweather-realtime.101599/
api-version: 1.21 api-version: 1.21
load: STARTUP load: STARTUP