This commit is contained in:
Minecon724 2022-04-24 16:13:32 +00:00
parent f894706f6c
commit e184902841
5 changed files with 20 additions and 11 deletions

View file

@ -44,10 +44,10 @@ public class GetStateTask extends BukkitRunnable {
@Override
public void run() {
logger.fine("Refreshing weather by " + source);
logger.info("Refreshing weather by " + source);
if (source.equals("point")) {
State state = provider.request_state(pointLatitude, pointLongitude);
logger.fine(String.format("Provider returned state %s %s", state.condition.name(), state.level.name()));
logger.info(String.format("Provider returned state %s %s (%s)", state.condition.name(), state.level.name(), state.simple.name()));
for (String w : worlds) {
World world = Bukkit.getWorld(w);
if (world == null) continue;
@ -67,11 +67,11 @@ public class GetStateTask extends BukkitRunnable {
location = client.city(playerIp).getLocation();
lat = location.getLatitude();
lon = location.getLongitude();
logger.fine( String.format(
logger.info( String.format(
"%s's location is %f, %f", p.getName(), lat, lon
));
state = provider.request_state(lat, lon);
logger.fine( String.format(
logger.info( String.format(
"Provider returned state %s %s for %s", state.condition.name(), state.level.name(), p.getName()
));
p.setPlayerWeather(state.simple == ConditionSimple.CLEAR ? WeatherType.CLEAR : WeatherType.DOWNFALL);

View file

@ -1,6 +1,7 @@
package pl.minecon724.realweather;
import java.util.List;
import java.util.logging.ConsoleHandler;
import java.util.logging.Level;
import com.maxmind.geoip2.WebServiceClient;
@ -28,11 +29,6 @@ public class RW extends JavaPlugin {
ConfigurationSection providerSec = config.getConfigurationSection("provider");
ConfigurationSection settingsSec = config.getConfigurationSection("settings");
if (settingsSec.getBoolean("debug")) {
this.getLogger().setLevel(Level.ALL);
this.getLogger().fine("Debug info will appear in the console");
}
String source = weatherSec.getString("source");
ConfigurationSection point = weatherSec.getConfigurationSection("point");
ConfigurationSection player = weatherSec.getConfigurationSection("player");

View file

@ -36,10 +36,12 @@ public class WeatherState {
switch (condition) {
case THUNDER:
this.simple = ConditionSimple.THUNDER;
break;
case DRIZZLE:
case RAIN:
case SNOW:
this.simple = ConditionSimple.RAIN;
break;
case CLEAR:
case CLOUDY:
this.simple = ConditionSimple.CLEAR;

View file

@ -63,11 +63,13 @@ public class OpenWeatherMapProvider implements Provider {
case 210:
case 230:
level = ConditionLevel.LIGHT;
break;
case 201:
case 211:
case 221:
case 231:
level = ConditionLevel.MODERATE;
break;
case 202:
case 212:
case 232:
@ -79,11 +81,13 @@ public class OpenWeatherMapProvider implements Provider {
case 300:
case 310:
level = ConditionLevel.LIGHT;
break;
case 301:
case 311:
case 313:
case 321:
level = ConditionLevel.MODERATE;
break;
case 302:
case 312:
case 314:
@ -95,14 +99,17 @@ public class OpenWeatherMapProvider implements Provider {
case 500:
case 520:
level = ConditionLevel.LIGHT;
break;
case 501:
case 511:
case 521:
case 531:
level = ConditionLevel.MODERATE;
break;
case 502:
case 522:
level = ConditionLevel.HEAVY;
break;
case 503:
case 504:
level = ConditionLevel.EXTREME;
@ -115,12 +122,14 @@ public class OpenWeatherMapProvider implements Provider {
case 615:
case 620:
level = ConditionLevel.LIGHT;
break;
case 601:
case 611:
case 613:
case 616:
case 621:
level = ConditionLevel.MODERATE;
break;
case 602:
case 622:
level = ConditionLevel.HEAVY;
@ -130,10 +139,13 @@ public class OpenWeatherMapProvider implements Provider {
switch (stateId) {
case 801:
level = ConditionLevel.LIGHT;
break;
case 802:
level = ConditionLevel.MODERATE;
break;
case 803:
level = ConditionLevel.HEAVY;
break;
case 804:
level = ConditionLevel.EXTREME;
}

View file

@ -32,5 +32,4 @@ settings:
timeBetweenRecheck: 600
# Advanced options
timeBeforeInitialRun: 0
debug: true
timeBeforeInitialRun: 0