Compare commits
10 commits
f596dad07f
...
7cdec756b8
Author | SHA1 | Date | |
---|---|---|---|
7cdec756b8 | |||
4239aba5b4 | |||
8f019b8cf5 | |||
c10119233f | |||
28c59a768a | |||
c645d56085 | |||
88df6c5781 | |||
35f8c5f882 | |||
7eac4a399f | |||
664eca4f3b |
12 changed files with 90 additions and 59 deletions
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal 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>
|
37
pom.xml
37
pom.xml
|
@ -12,22 +12,6 @@
|
||||||
<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>
|
||||||
|
@ -133,4 +117,19 @@
|
||||||
</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
13
realweather.iml
Normal 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>
|
|
@ -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;
|
||||||
|
|
|
@ -51,14 +51,7 @@ 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");
|
||||||
|
@ -74,11 +67,19 @@ public class RealWeatherPlugin extends JavaPlugin {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,16 +15,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,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue