almost there

This commit is contained in:
Minecon724 2022-04-23 17:57:57 +00:00
parent 3486a1c36b
commit 358828ef56
5 changed files with 97 additions and 8 deletions

View 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
View file

@ -37,5 +37,28 @@
<filtering>true</filtering>
</resource>
</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>
</project>

View file

@ -30,8 +30,10 @@ public class GetStateTask extends BukkitRunnable {
@Override
public void run() {
if (source == "point") {
Bukkit.getLogger().fine("Refreshing weather by " + source);
if (source.equals("point")) {
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) {
World world = Bukkit.getWorld(w);
if (world == null) continue;

View file

@ -1,6 +1,7 @@
package pl.minecon724.realweather;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.configuration.ConfigurationSection;
@ -18,10 +19,15 @@ public class RW extends JavaPlugin {
saveDefaultConfig();
config = getConfig();
ConfigurationSection weatherSec = config.getConfigurationSection("weather");
ConfigurationSection providerSec = config.getConfigurationSection("provider");
ConfigurationSection settingsSec = config.getConfigurationSection("settings");
if (settingsSec.getBoolean("debug")) {
Bukkit.getLogger().setLevel(Level.ALL);
}
String source = weatherSec.getString("source");
ConfigurationSection point = weatherSec.getConfigurationSection("point");
@ -38,8 +44,8 @@ public class RW extends JavaPlugin {
Bukkit.getPluginManager().disablePlugin(this);
}
Provider provider;
if (choice == "openweathermap") {
Provider provider = null;
if (choice.equals("openweathermap")) {
Bukkit.getLogger().info("Using OpenWeatherMap as the weather provider");
provider = new OpenWeatherMapProvider( providerCfg.getString("apiKey") );
}
@ -53,6 +59,6 @@ public class RW extends JavaPlugin {
);
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 ) ) );
}
}

View file

@ -6,7 +6,7 @@ weather:
- second_world
- third_world
# Point for a static location
# Fake weather and player locations not implemented yet
# Weather by player's real location soon
source: point
point:
latitude: 41.84201
@ -23,8 +23,11 @@ provider:
# More providers soon!
settings:
# Delay between rechecking weather
# 20 is one second
timeBetweenRecheck: 1200
# Shouldn't affect performance
timeBetweenRecheck: 600
# Advanced options here
timeBeforeInitialRun: 0
# Advanced options
timeBeforeInitialRun: 0
debug: true