diff --git a/.classpath b/.classpath index 1df54b7..2046887 100644 --- a/.classpath +++ b/.classpath @@ -3,6 +3,7 @@ + @@ -36,6 +37,13 @@ + + + + + + + diff --git a/.gitignore b/.gitignore index fc56929..78d5d41 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ target/ -# CLI files +# IDE files org.eclipse.* -.vscode/ \ No newline at end of file +.vscode/ +.classpath +.project \ No newline at end of file diff --git a/.project b/.project index 2678c1a..85fb494 100644 --- a/.project +++ b/.project @@ -22,12 +22,12 @@ - 1650700979358 + 1693298440613 30 org.eclipse.core.resources.regexFilterMatcher - node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ diff --git a/pom.xml b/pom.xml index 7316ce3..da0d33d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 pl.minecon724 realweather - 0.4.0 + 0.4.1 17 @@ -20,7 +20,7 @@ org.spigotmc spigot-api - 1.18.2-R0.1-SNAPSHOT + 1.20.1-R0.1-SNAPSHOT provided @@ -32,7 +32,7 @@ com.maxmind.geoip2 geoip2 - 3.0.1 + 4.1.0 provided diff --git a/src/main/java/pl/minecon724/realweather/RW.java b/src/main/java/pl/minecon724/realweather/RW.java index 8458480..08d4570 100644 --- a/src/main/java/pl/minecon724/realweather/RW.java +++ b/src/main/java/pl/minecon724/realweather/RW.java @@ -94,7 +94,7 @@ public class RW extends JavaPlugin { realtimeSec.getDouble("timeScale"), zone, realtimeSec.getStringList("worlds") - ).runTaskTimerAsynchronously(this, 0, realtimeSec.getLong("interval")); + ).runTaskTimer(this, 0, realtimeSec.getLong("interval")); } Metrics metrics = new Metrics(this, 15020); diff --git a/src/main/java/pl/minecon724/realweather/realtime/RTTask.java b/src/main/java/pl/minecon724/realweather/realtime/RTTask.java index 184463b..80ea609 100644 --- a/src/main/java/pl/minecon724/realweather/realtime/RTTask.java +++ b/src/main/java/pl/minecon724/realweather/realtime/RTTask.java @@ -1,6 +1,5 @@ package pl.minecon724.realweather.realtime; -import java.time.OffsetDateTime; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; @@ -29,7 +28,17 @@ public class RTTask extends BukkitRunnable { @Override public void run() { long now = ZonedDateTime.now(timezone).toInstant().getEpochSecond(); - double time = now / 72 - 18000; + now *= timeScale; + now %= 86400; + + // day irl is 86400 secs + // in game, its 1200 secs + // to align, 86400 / 1200 = 72 + // then we convert to ticks by multiplying 20 (1s = 20t) + // we subtract 24000 - 18000 = 6000 because 18000 is midnight + double time = (now / 72.0) * 20 - 6000; + time %= 24000; + for (World w : worlds) { w.setFullTime((long)time); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 961e2f4..3570e7c 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,23 +1,20 @@ weather: - # In which worlds weather control is allowed? - # If a world doesn't exist nothing will happen worlds: - world - second_world - third_world # "point" - static location - # "player" - player's location (fake weather) + # "player" - player's IP location (fake weather) # "map" - world resembles a real-world globe source: point point: latitude: 41.84201 longitude: -89.485937 player: + # Get your own @ https://www.maxmind.com/en/geolite2/signup geolite2_accountId: 710438 - geolite2_apiKey: 'qLeseHp4QNQcqRGn' # Get your own @ https://www.maxmind.com/en/geolite2/signup + geolite2_apiKey: 'qLeseHp4QNQcqRGn' map: - # Man I've really suffered while working on this one (i hate maths) - # Info: # Valid latitude range: -90 to 90 # Valid longitude range: -180 to 180 # 1 degree of latitude and longitude is about 111 km @@ -29,20 +26,19 @@ weather: # What to do if player exceeds the range specified above # 1 - do nothing (clamp to nearest allowed value) # 2 - wrap the number - # for example; if the calculated player's latitude is 94 degrees (bad), it'll be converted to -86 degrees (good) + # for example; if a player's position on map converts to 94 degrees (out of bounds), it becomes -86 degrees on_exceed: 2 provider: - # Your provider choice - # Case insensitive + # Weather provider choice: openweathermap - # Provider settings here - # Unlike the previous option, these are case sensitive + # Configure it here openweathermap: apiKey: 'd3d37fd3511ef1d4b44c7d574e9b56b8' # PLEASE get your own @ https://home.openweathermap.org/users/sign_up # More providers soon! realtime: + # warning: this removes sleep enabled: false worlds: - world @@ -50,15 +46,14 @@ realtime: # Alternatively choose one of these: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List timezone: 'auto' # x day cycles / 24 hrs - # Not implemented yet timeScale: 1.0 # How often should we recalculate the time (in ticks) - # Very minimal, if any, impact on performance + # Very minimal impact on performance interval: 1 settings: # Delay between rechecking weather - # 20 is one second + # in ticks, 20 is one second # Shouldn't affect performance timeBetweenRecheck: 600 # Whether to display an actionbar containing info @@ -70,6 +65,7 @@ settings: debugAllowDox: false messages: + # settings.actionbar toggles this # %weather_full% - full state description, such as "extreme thunder" # %weather% - short state description, such as "rain" actionbarInfo: "&b%weather_full%" diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5b26d3e..4206008 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -5,7 +5,7 @@ author: Minecon724 main: pl.minecon724.realweather.RW libraries: - org.json:json:20220320 - - com.maxmind.geoip2:geoip2:3.0.1 + - com.maxmind.geoip2:geoip2:4.1.0 commands: realweather: alias: rw