almost there
This commit is contained in:
parent
3486a1c36b
commit
358828ef56
5 changed files with 97 additions and 8 deletions
55
dependency-reduced-pom.xml
Normal file
55
dependency-reduced-pom.xml
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>pl.minecon724</groupId>
|
||||||
|
<artifactId>realweather</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<build>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>org.json:json</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
</properties>
|
||||||
|
</project>
|
23
pom.xml
23
pom.xml
|
@ -37,5 +37,28 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>org.json:json</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
|
@ -30,8 +30,10 @@ public class GetStateTask extends BukkitRunnable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (source == "point") {
|
Bukkit.getLogger().fine("Refreshing weather by " + source);
|
||||||
|
if (source.equals("point")) {
|
||||||
State state = provider.request_state(pointLatitude, pointLongitude);
|
State state = provider.request_state(pointLatitude, pointLongitude);
|
||||||
|
Bukkit.getLogger().fine(String.format("Provider returned state %s %s", state.condition.name(), state.level.name()));
|
||||||
for (String w : worlds) {
|
for (String w : worlds) {
|
||||||
World world = Bukkit.getWorld(w);
|
World world = Bukkit.getWorld(w);
|
||||||
if (world == null) continue;
|
if (world == null) continue;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package pl.minecon724.realweather;
|
package pl.minecon724.realweather;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
@ -18,10 +19,15 @@ public class RW extends JavaPlugin {
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
config = getConfig();
|
config = getConfig();
|
||||||
|
|
||||||
ConfigurationSection weatherSec = config.getConfigurationSection("weather");
|
ConfigurationSection weatherSec = config.getConfigurationSection("weather");
|
||||||
ConfigurationSection providerSec = config.getConfigurationSection("provider");
|
ConfigurationSection providerSec = config.getConfigurationSection("provider");
|
||||||
ConfigurationSection settingsSec = config.getConfigurationSection("settings");
|
ConfigurationSection settingsSec = config.getConfigurationSection("settings");
|
||||||
|
|
||||||
|
if (settingsSec.getBoolean("debug")) {
|
||||||
|
Bukkit.getLogger().setLevel(Level.ALL);
|
||||||
|
}
|
||||||
|
|
||||||
String source = weatherSec.getString("source");
|
String source = weatherSec.getString("source");
|
||||||
ConfigurationSection point = weatherSec.getConfigurationSection("point");
|
ConfigurationSection point = weatherSec.getConfigurationSection("point");
|
||||||
|
|
||||||
|
@ -38,8 +44,8 @@ public class RW extends JavaPlugin {
|
||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Provider provider;
|
Provider provider = null;
|
||||||
if (choice == "openweathermap") {
|
if (choice.equals("openweathermap")) {
|
||||||
Bukkit.getLogger().info("Using OpenWeatherMap as the weather provider");
|
Bukkit.getLogger().info("Using OpenWeatherMap as the weather provider");
|
||||||
provider = new OpenWeatherMapProvider( providerCfg.getString("apiKey") );
|
provider = new OpenWeatherMapProvider( providerCfg.getString("apiKey") );
|
||||||
}
|
}
|
||||||
|
@ -53,6 +59,6 @@ public class RW extends JavaPlugin {
|
||||||
);
|
);
|
||||||
|
|
||||||
long end = System.currentTimeMillis();
|
long end = System.currentTimeMillis();
|
||||||
Bukkit.getLogger().info( String.format( this.getName() + "enabled! (%s ms)", Double.toString( Math.ceil(end-start) ) ) );
|
Bukkit.getLogger().info( String.format( this.getName() + " enabled! (%s ms)", Long.toString( end-start ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ weather:
|
||||||
- second_world
|
- second_world
|
||||||
- third_world
|
- third_world
|
||||||
# Point for a static location
|
# Point for a static location
|
||||||
# Fake weather and player locations not implemented yet
|
# Weather by player's real location soon
|
||||||
source: point
|
source: point
|
||||||
point:
|
point:
|
||||||
latitude: 41.84201
|
latitude: 41.84201
|
||||||
|
@ -23,8 +23,11 @@ provider:
|
||||||
# More providers soon!
|
# More providers soon!
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
|
# Delay between rechecking weather
|
||||||
# 20 is one second
|
# 20 is one second
|
||||||
timeBetweenRecheck: 1200
|
# Shouldn't affect performance
|
||||||
|
timeBetweenRecheck: 600
|
||||||
|
|
||||||
# Advanced options here
|
# Advanced options
|
||||||
timeBeforeInitialRun: 0
|
timeBeforeInitialRun: 0
|
||||||
|
debug: true
|
Loading…
Reference in a new issue