parent
33055172e4
commit
e2254f6c67
8 changed files with 40 additions and 25 deletions
|
@ -3,6 +3,7 @@
|
||||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="maven.pomderived" value="true"/>
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-17">
|
||||||
|
@ -36,6 +37,13 @@
|
||||||
<attribute name="test" value="true"/>
|
<attribute name="test" value="true"/>
|
||||||
</attributes>
|
</attributes>
|
||||||
</classpathentry>
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
|
||||||
<attributes>
|
<attributes>
|
||||||
<attribute name="optional" value="true"/>
|
<attribute name="optional" value="true"/>
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,5 +1,7 @@
|
||||||
target/
|
target/
|
||||||
|
|
||||||
# CLI files
|
# IDE files
|
||||||
org.eclipse.*
|
org.eclipse.*
|
||||||
.vscode/
|
.vscode/
|
||||||
|
.classpath
|
||||||
|
.project
|
4
.project
4
.project
|
@ -22,12 +22,12 @@
|
||||||
</natures>
|
</natures>
|
||||||
<filteredResources>
|
<filteredResources>
|
||||||
<filter>
|
<filter>
|
||||||
<id>1650700979358</id>
|
<id>1693298440613</id>
|
||||||
<name></name>
|
<name></name>
|
||||||
<type>30</type>
|
<type>30</type>
|
||||||
<matcher>
|
<matcher>
|
||||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||||
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||||
</matcher>
|
</matcher>
|
||||||
</filter>
|
</filter>
|
||||||
</filteredResources>
|
</filteredResources>
|
||||||
|
|
6
pom.xml
6
pom.xml
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pl.minecon724</groupId>
|
<groupId>pl.minecon724</groupId>
|
||||||
<artifactId>realweather</artifactId>
|
<artifactId>realweather</artifactId>
|
||||||
<version>0.4.0</version>
|
<version>0.4.1</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source>17</maven.compiler.source>
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.maxmind.geoip2</groupId>
|
<groupId>com.maxmind.geoip2</groupId>
|
||||||
<artifactId>geoip2</artifactId>
|
<artifactId>geoip2</artifactId>
|
||||||
<version>3.0.1</version>
|
<version>4.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class RW extends JavaPlugin {
|
||||||
realtimeSec.getDouble("timeScale"),
|
realtimeSec.getDouble("timeScale"),
|
||||||
zone,
|
zone,
|
||||||
realtimeSec.getStringList("worlds")
|
realtimeSec.getStringList("worlds")
|
||||||
).runTaskTimerAsynchronously(this, 0, realtimeSec.getLong("interval"));
|
).runTaskTimer(this, 0, realtimeSec.getLong("interval"));
|
||||||
}
|
}
|
||||||
|
|
||||||
Metrics metrics = new Metrics(this, 15020);
|
Metrics metrics = new Metrics(this, 15020);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package pl.minecon724.realweather.realtime;
|
package pl.minecon724.realweather.realtime;
|
||||||
|
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,7 +28,17 @@ public class RTTask extends BukkitRunnable {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long now = ZonedDateTime.now(timezone).toInstant().getEpochSecond();
|
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) {
|
for (World w : worlds) {
|
||||||
w.setFullTime((long)time);
|
w.setFullTime((long)time);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,23 +1,20 @@
|
||||||
weather:
|
weather:
|
||||||
# In which worlds weather control is allowed?
|
|
||||||
# If a world doesn't exist nothing will happen
|
|
||||||
worlds:
|
worlds:
|
||||||
- world
|
- world
|
||||||
- second_world
|
- second_world
|
||||||
- third_world
|
- third_world
|
||||||
# "point" - static location
|
# "point" - static location
|
||||||
# "player" - player's location (fake weather)
|
# "player" - player's IP location (fake weather)
|
||||||
# "map" - world resembles a real-world globe
|
# "map" - world resembles a real-world globe
|
||||||
source: point
|
source: point
|
||||||
point:
|
point:
|
||||||
latitude: 41.84201
|
latitude: 41.84201
|
||||||
longitude: -89.485937
|
longitude: -89.485937
|
||||||
player:
|
player:
|
||||||
|
# Get your own @ https://www.maxmind.com/en/geolite2/signup
|
||||||
geolite2_accountId: 710438
|
geolite2_accountId: 710438
|
||||||
geolite2_apiKey: 'qLeseHp4QNQcqRGn' # Get your own @ https://www.maxmind.com/en/geolite2/signup
|
geolite2_apiKey: 'qLeseHp4QNQcqRGn'
|
||||||
map:
|
map:
|
||||||
# Man I've really suffered while working on this one (i hate maths)
|
|
||||||
# Info:
|
|
||||||
# Valid latitude range: -90 to 90
|
# Valid latitude range: -90 to 90
|
||||||
# Valid longitude range: -180 to 180
|
# Valid longitude range: -180 to 180
|
||||||
# 1 degree of latitude and longitude is about 111 km
|
# 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
|
# What to do if player exceeds the range specified above
|
||||||
# 1 - do nothing (clamp to nearest allowed value)
|
# 1 - do nothing (clamp to nearest allowed value)
|
||||||
# 2 - wrap the number
|
# 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
|
on_exceed: 2
|
||||||
|
|
||||||
provider:
|
provider:
|
||||||
# Your provider choice
|
# Weather provider
|
||||||
# Case insensitive
|
|
||||||
choice: openweathermap
|
choice: openweathermap
|
||||||
# Provider settings here
|
# Configure it here
|
||||||
# Unlike the previous option, these are case sensitive
|
|
||||||
openweathermap:
|
openweathermap:
|
||||||
apiKey: 'd3d37fd3511ef1d4b44c7d574e9b56b8' # PLEASE get your own @ https://home.openweathermap.org/users/sign_up
|
apiKey: 'd3d37fd3511ef1d4b44c7d574e9b56b8' # PLEASE get your own @ https://home.openweathermap.org/users/sign_up
|
||||||
# More providers soon!
|
# More providers soon!
|
||||||
|
|
||||||
realtime:
|
realtime:
|
||||||
|
# warning: this removes sleep
|
||||||
enabled: false
|
enabled: false
|
||||||
worlds:
|
worlds:
|
||||||
- world
|
- world
|
||||||
|
@ -50,15 +46,14 @@ realtime:
|
||||||
# Alternatively choose one of these: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
|
# Alternatively choose one of these: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
|
||||||
timezone: 'auto'
|
timezone: 'auto'
|
||||||
# x day cycles / 24 hrs
|
# x day cycles / 24 hrs
|
||||||
# Not implemented yet
|
|
||||||
timeScale: 1.0
|
timeScale: 1.0
|
||||||
# How often should we recalculate the time (in ticks)
|
# How often should we recalculate the time (in ticks)
|
||||||
# Very minimal, if any, impact on performance
|
# Very minimal impact on performance
|
||||||
interval: 1
|
interval: 1
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
# Delay between rechecking weather
|
# Delay between rechecking weather
|
||||||
# 20 is one second
|
# in ticks, 20 is one second
|
||||||
# Shouldn't affect performance
|
# Shouldn't affect performance
|
||||||
timeBetweenRecheck: 600
|
timeBetweenRecheck: 600
|
||||||
# Whether to display an actionbar containing info
|
# Whether to display an actionbar containing info
|
||||||
|
@ -70,6 +65,7 @@ settings:
|
||||||
debugAllowDox: false
|
debugAllowDox: false
|
||||||
|
|
||||||
messages:
|
messages:
|
||||||
|
# settings.actionbar toggles this
|
||||||
# %weather_full% - full state description, such as "extreme thunder"
|
# %weather_full% - full state description, such as "extreme thunder"
|
||||||
# %weather% - short state description, such as "rain"
|
# %weather% - short state description, such as "rain"
|
||||||
actionbarInfo: "&b%weather_full%"
|
actionbarInfo: "&b%weather_full%"
|
||||||
|
|
|
@ -5,7 +5,7 @@ author: Minecon724
|
||||||
main: pl.minecon724.realweather.RW
|
main: pl.minecon724.realweather.RW
|
||||||
libraries:
|
libraries:
|
||||||
- org.json:json:20220320
|
- org.json:json:20220320
|
||||||
- com.maxmind.geoip2:geoip2:3.0.1
|
- com.maxmind.geoip2:geoip2:4.1.0
|
||||||
commands:
|
commands:
|
||||||
realweather:
|
realweather:
|
||||||
alias: rw
|
alias: rw
|
||||||
|
|
Loading…
Reference in a new issue