No major refactoring
This commit is contained in:
		
					parent
					
						
							
								1920d8dcc2
							
						
					
				
			
			
				commit
				
					
						7927d8ba3e
					
				
			
		
					 19 changed files with 152 additions and 165 deletions
				
			
		
							
								
								
									
										2
									
								
								.idea/modules.xml
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.idea/modules.xml
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -2,7 +2,7 @@
 | 
				
			||||||
<project version="4">
 | 
					<project version="4">
 | 
				
			||||||
  <component name="ProjectModuleManager">
 | 
					  <component name="ProjectModuleManager">
 | 
				
			||||||
    <modules>
 | 
					    <modules>
 | 
				
			||||||
      <module fileurl="file://$PROJECT_DIR$/realweather.iml" filepath="$PROJECT_DIR$/realweather.iml" />
 | 
					      <module fileurl="file://$PROJECT_DIR$/.idea/realweather.iml" filepath="$PROJECT_DIR$/.idea/realweather.iml" />
 | 
				
			||||||
    </modules>
 | 
					    </modules>
 | 
				
			||||||
  </component>
 | 
					  </component>
 | 
				
			||||||
</project>
 | 
					</project>
 | 
				
			||||||
							
								
								
									
										13
									
								
								.idea/realweather.iml
									
										
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.idea/realweather.iml
									
										
									
										generated
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					<?xml version="1.0" encoding="UTF-8"?>
 | 
				
			||||||
 | 
					<module version="4">
 | 
				
			||||||
 | 
					  <component name="FacetManager">
 | 
				
			||||||
 | 
					    <facet type="minecraft" name="Minecraft">
 | 
				
			||||||
 | 
					      <configuration>
 | 
				
			||||||
 | 
					        <autoDetectTypes>
 | 
				
			||||||
 | 
					          <platformType>SPIGOT</platformType>
 | 
				
			||||||
 | 
					        </autoDetectTypes>
 | 
				
			||||||
 | 
					        <projectReimportVersion>1</projectReimportVersion>
 | 
				
			||||||
 | 
					      </configuration>
 | 
				
			||||||
 | 
					    </facet>
 | 
				
			||||||
 | 
					  </component>
 | 
				
			||||||
 | 
					</module>
 | 
				
			||||||
							
								
								
									
										2
									
								
								pom.xml
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
										
									
									
									
								
							| 
						 | 
					@ -46,7 +46,7 @@
 | 
				
			||||||
		<dependency>
 | 
							<dependency>
 | 
				
			||||||
			<groupId>eu.m724</groupId>
 | 
								<groupId>eu.m724</groupId>
 | 
				
			||||||
		    <artifactId>wtapi</artifactId>
 | 
							    <artifactId>wtapi</artifactId>
 | 
				
			||||||
		    <version>0.8.3</version>
 | 
							    <version>0.9.2</version>
 | 
				
			||||||
		</dependency>
 | 
							</dependency>
 | 
				
			||||||
		<dependency>
 | 
							<dependency>
 | 
				
			||||||
			<groupId>eu.m724</groupId>
 | 
								<groupId>eu.m724</groupId>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,6 +7,7 @@ import java.io.InputStreamReader;
 | 
				
			||||||
import java.nio.charset.StandardCharsets;
 | 
					import java.nio.charset.StandardCharsets;
 | 
				
			||||||
import java.util.logging.Logger;
 | 
					import java.util.logging.Logger;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
				
			||||||
import org.bukkit.configuration.file.YamlConfiguration;
 | 
					import org.bukkit.configuration.file.YamlConfiguration;
 | 
				
			||||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,7 +27,6 @@ import eu.m724.realweather.updater.UpdaterConfig;
 | 
				
			||||||
import eu.m724.realweather.weather.PlayerWeatherCache;
 | 
					import eu.m724.realweather.weather.PlayerWeatherCache;
 | 
				
			||||||
import eu.m724.realweather.weather.WeatherConfig;
 | 
					import eu.m724.realweather.weather.WeatherConfig;
 | 
				
			||||||
import eu.m724.realweather.weather.WeatherMaster;
 | 
					import eu.m724.realweather.weather.WeatherMaster;
 | 
				
			||||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.provider.exception.ProviderException;
 | 
					import eu.m724.wtapi.provider.exception.ProviderException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO unmess this too
 | 
					// TODO unmess this too
 | 
				
			||||||
| 
						 | 
					@ -110,8 +110,8 @@ public class RealWeatherPlugin extends JavaPlugin {
 | 
				
			||||||
			updater = PluginUpdater.build(this, this.getFile());
 | 
								updater = PluginUpdater.build(this, this.getFile());
 | 
				
			||||||
			//updater.init();
 | 
								//updater.init();
 | 
				
			||||||
		} catch (UserError | NoSuchProviderException e) {
 | 
							} catch (UserError | NoSuchProviderException e) {
 | 
				
			||||||
			logger.severe("There are errors in your config:");
 | 
								logger.severe("There's an error in your config:");
 | 
				
			||||||
			logger.severe(e.getMessage());
 | 
								logger.severe(" " + e.getMessage());
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
			getServer().getPluginManager().disablePlugin(this);
 | 
								getServer().getPluginManager().disablePlugin(this);
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,8 +1,5 @@
 | 
				
			||||||
package eu.m724.realweather.commands;
 | 
					package eu.m724.realweather.commands;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.md_5.bungee.api.chat.*;
 | 
					 | 
				
			||||||
import net.md_5.bungee.api.chat.hover.content.Content;
 | 
					 | 
				
			||||||
import net.md_5.bungee.api.chat.hover.content.Text;
 | 
					 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.command.Command;
 | 
					import org.bukkit.command.Command;
 | 
				
			||||||
import org.bukkit.command.CommandExecutor;
 | 
					import org.bukkit.command.CommandExecutor;
 | 
				
			||||||
| 
						 | 
					@ -11,13 +8,11 @@ import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.m724.realweather.GlobalConstants;
 | 
					import eu.m724.realweather.GlobalConstants;
 | 
				
			||||||
import eu.m724.realweather.mapper.Mapper;
 | 
					import eu.m724.realweather.mapper.Mapper;
 | 
				
			||||||
import eu.m724.realweather.weather.PlayerWeatherCache;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.object.Coordinates;
 | 
					import eu.m724.wtapi.object.Coordinates;
 | 
				
			||||||
import eu.m724.wtapi.object.Weather;
 | 
					 | 
				
			||||||
import net.md_5.bungee.api.ChatColor;
 | 
					import net.md_5.bungee.api.ChatColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class GeoCommand implements CommandExecutor {
 | 
					public class GeoCommand implements CommandExecutor {
 | 
				
			||||||
	private final PlayerWeatherCache playerWeatherCache = GlobalConstants.getPlayerWeatherCache();
 | 
						//private final PlayerWeatherCache playerWeatherCache = GlobalConstants.getPlayerWeatherCache();
 | 
				
			||||||
	private final Mapper mapper = GlobalConstants.getMapper();
 | 
						private final Mapper mapper = GlobalConstants.getMapper();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
| 
						 | 
					@ -29,14 +24,16 @@ public class GeoCommand implements CommandExecutor {
 | 
				
			||||||
				Location location = player.getLocation();
 | 
									Location location = player.getLocation();
 | 
				
			||||||
				Coordinates coordinates = mapper.locationToCoordinates(location);
 | 
									Coordinates coordinates = mapper.locationToCoordinates(location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Weather weather = playerWeatherCache.getWeather(player);
 | 
									//Weather weather = playerWeatherCache.getWeather(player);
 | 
				
			||||||
				String address = formatAddress(weather);
 | 
									//String address = formatAddress(weather);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				colorize(player, "");
 | 
									colorize(player, "");
 | 
				
			||||||
				colorize(player, "&6Geolocation: &b%f&7, %b%f &7(lat, lon)", coordinates.latitude, coordinates.longitude);
 | 
									colorize(player, "&6Geolocation: &b%f&7, &b%f &7(lat, lon)", coordinates.latitude(), coordinates.longitude());
 | 
				
			||||||
				colorize(player, "&7Position: &3%f&8, %3%f &8(x, z)", location.getX(), location.getZ());
 | 
									colorize(player, "&7In-game Position: &3%f&8, &3%f &8(x, z)", location.getX(), location.getZ());
 | 
				
			||||||
				colorize(player, "&7City: &3%s", address);
 | 
									//colorize(player, "&7City: &3%s", address);
 | 
				
			||||||
				colorize(player, "");
 | 
									colorize(player, "");
 | 
				
			||||||
 | 
								} else {
 | 
				
			||||||
 | 
									sender.sendMessage("You can't run this command without arguments as console");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		} else if (args.length >= 3) {
 | 
							} else if (args.length >= 3) {
 | 
				
			||||||
			colorize(sender, "&cInvalid arguments, &7make sure it's &a\"/geo lat,lon\" &7or &a\"/geo x z\" &7or just &a\"/geo\"");
 | 
								colorize(sender, "&cInvalid arguments, &7make sure it's &a\"/geo lat,lon\" &7or &a\"/geo x z\" &7or just &a\"/geo\"");
 | 
				
			||||||
| 
						 | 
					@ -55,12 +52,10 @@ public class GeoCommand implements CommandExecutor {
 | 
				
			||||||
			Coordinates coordinates = mapper.locationToCoordinates(location);
 | 
								Coordinates coordinates = mapper.locationToCoordinates(location);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			colorize(sender, "");
 | 
								colorize(sender, "");
 | 
				
			||||||
			colorize(sender, "&6Position: &b%f&7, %b%f &7(x, z)", location.getX(), location.getZ());
 | 
								colorize(sender, "&6In-game Position: &b%f&7, &b%f &7(x, z)", location.getX(), location.getZ());
 | 
				
			||||||
			colorize(sender, "&7Geolocation: &3%f&8, %3%f &8(lat, lon)", coordinates.latitude, coordinates.longitude);
 | 
								colorize(sender, "&7Geolocation: &3%f&8, &3%f &8(lat, lon)", coordinates.latitude(), coordinates.longitude());
 | 
				
			||||||
			colorize(sender, "&7Input interpreted as position, because you separated with a space");
 | 
								colorize(sender, "&7Input interpreted as position, because you separated it with a space");
 | 
				
			||||||
			colorize(sender, "");
 | 
								colorize(sender, "");
 | 
				
			||||||
 | 
					 | 
				
			||||||
			return true;
 | 
					 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			double latitude, longitude;
 | 
								double latitude, longitude;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,8 +72,8 @@ public class GeoCommand implements CommandExecutor {
 | 
				
			||||||
			Location location = mapper.coordinatesToLocation(null, coordinates);
 | 
								Location location = mapper.coordinatesToLocation(null, coordinates);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			colorize(sender, "");
 | 
								colorize(sender, "");
 | 
				
			||||||
			colorize(sender, "&6Position: &b%f&7, %b%f &7(x, z)", location.getX(), location.getZ());
 | 
								colorize(sender, "&6In-game Position: &b%f&7, &b%f &7(x, z)", location.getX(), location.getZ());
 | 
				
			||||||
			colorize(sender, "&7Geolocation: &3%f&8, %3%f &8(lat, lon)", coordinates.latitude, coordinates.longitude);
 | 
								colorize(sender, "&7Geolocation: &3%f&8, &3%f &8(lat, lon)", coordinates.latitude(), coordinates.longitude());
 | 
				
			||||||
			colorize(sender, "&7Input interpreted as geolocation, because you separated with a comma");
 | 
								colorize(sender, "&7Input interpreted as geolocation, because you separated with a comma");
 | 
				
			||||||
			colorize(sender, "");
 | 
								colorize(sender, "");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					@ -89,18 +84,4 @@ public class GeoCommand implements CommandExecutor {
 | 
				
			||||||
	private void colorize(CommandSender sender, String text, Object... format) {
 | 
						private void colorize(CommandSender sender, String text, Object... format) {
 | 
				
			||||||
		sender.sendMessage(ChatColor.translateAlternateColorCodes('&', text.formatted(format)));
 | 
							sender.sendMessage(ChatColor.translateAlternateColorCodes('&', text.formatted(format)));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	private String formatAddress(Weather weather) {
 | 
					 | 
				
			||||||
		if (weather == null) return "Not retrieved yet";
 | 
					 | 
				
			||||||
		Coordinates coordinates = weather.coordinates;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if (coordinates.country == null && coordinates.city == null)
 | 
					 | 
				
			||||||
			return "Unknown";
 | 
					 | 
				
			||||||
		else if (coordinates.city == null)
 | 
					 | 
				
			||||||
			return "Somewhere in " + coordinates.country;
 | 
					 | 
				
			||||||
		else if (coordinates.country == null)
 | 
					 | 
				
			||||||
			return coordinates.city;
 | 
					 | 
				
			||||||
		return coordinates.city + ", " + coordinates.country;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,7 @@ public class LocalTimeCommand implements CommandExecutor {
 | 
				
			||||||
		if (timeConfig.dynamic() && player != null && player.hasPermission("realweather.dynamic")) {
 | 
							if (timeConfig.dynamic() && player != null && player.hasPermission("realweather.dynamic")) {
 | 
				
			||||||
			Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
 | 
								Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			long offsetTime = timeConverter.calculateZoneOffset(coordinates.longitude);
 | 
								long offsetTime = timeConverter.calculateZoneOffset(coordinates.longitude());
 | 
				
			||||||
			long offsetTimeTicks = timeConverter.millisToTicks(offsetTime);
 | 
								long offsetTimeTicks = timeConverter.millisToTicks(offsetTime);
 | 
				
			||||||
			boolean negative = offsetTime < 0;
 | 
								boolean negative = offsetTime < 0;
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,6 +3,8 @@ package eu.m724.realweather.commands;
 | 
				
			||||||
import java.time.Instant;
 | 
					import java.time.Instant;
 | 
				
			||||||
import java.time.ZoneOffset;
 | 
					import java.time.ZoneOffset;
 | 
				
			||||||
import java.time.format.DateTimeFormatter;
 | 
					import java.time.format.DateTimeFormatter;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import net.md_5.bungee.api.ChatColor;
 | 
					import net.md_5.bungee.api.ChatColor;
 | 
				
			||||||
import org.bukkit.command.Command;
 | 
					import org.bukkit.command.Command;
 | 
				
			||||||
| 
						 | 
					@ -28,25 +30,24 @@ public class LocalWeatherCommand implements CommandExecutor {
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (weather != null) {
 | 
							if (weather != null) {
 | 
				
			||||||
			long lastUpdate = playerWeatherCache.getLastUpdate(player);
 | 
								long lastUpdate = playerWeatherCache.getLastUpdate(player);
 | 
				
			||||||
			colorize(sender, "\n&e" + weather.description);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (weather.rainSeverity != null)
 | 
								colorize(sender, "&6Weather for: &b%f&7, &b%f &7(lat, lon)\n", weather.coordinates().latitude(), weather.coordinates().longitude());
 | 
				
			||||||
				colorize(sender, "&6Rain: &b%s", weather.rainSeverity.toString());
 | 
					
 | 
				
			||||||
			if (weather.drizzleSeverity != null)
 | 
								List<String> states = new ArrayList<>(3);
 | 
				
			||||||
				colorize(sender, "&6Drizzle: &b%s", weather.drizzleSeverity.toString());
 | 
					
 | 
				
			||||||
			if (weather.sleetSeverity != null)
 | 
								if (weather.raining()) states.add("Raining");
 | 
				
			||||||
				colorize(sender, "&6Sleet: &b%s", weather.sleetSeverity.toString());
 | 
								if (weather.thundering()) states.add("Thundering");
 | 
				
			||||||
			if (weather.snowSeverity != null)
 | 
								if (weather.thundering()) states.add("Snowing");
 | 
				
			||||||
				colorize(sender, "&6Snow: &b%s", weather.snowSeverity.toString());
 | 
					
 | 
				
			||||||
			if (weather.thunderstormSeverity != null)
 | 
								if (!states.isEmpty()) {
 | 
				
			||||||
				colorize(sender, "&6Thunderstorm: &b%s", weather.thunderstormSeverity.toString());
 | 
									colorize(sender, "&6" + String.join(", ", states));
 | 
				
			||||||
			if (weather.shower)
 | 
								}
 | 
				
			||||||
				colorize(sender, "&6Shower");
 | 
					
 | 
				
			||||||
 | 
								colorize(sender, "&6Temperature: &b%.1f&7°C (feels like %.1f°C)", weather.temperatureCelsius(), weather.temperatureApparentCelsius());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								colorize(sender, "&6Cloud cover (cloudiness): &b%.0f&7%%", weather.cloudCoverPercentage() * 100);
 | 
				
			||||||
 | 
								colorize(sender, "&6Relative humidity: &b%.0f&7%%", weather.relativeHumidityPercentage() * 100);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			colorize(sender, "&6Cloudiness: &b%f&7%%", weather.cloudiness * 100);
 | 
					 | 
				
			||||||
			colorize(sender, "&6Humidity: &b%f&7%%", weather.humidity * 100);
 | 
					 | 
				
			||||||
			colorize(sender, "&6Temperature: &b%f&7°C (feels like %f°C)", weather.temperature - 273.15, weather.temperatureApparent - 273.15);
 | 
					 | 
				
			||||||
			colorize(sender, "&6Wind: &b%f&7m/s (gust %fm/s)", weather.windSpeed, weather.windGust);
 | 
					 | 
				
			||||||
			colorize(sender, "&6Last update: &b%s UTC\n", formatTime(lastUpdate));
 | 
								colorize(sender, "&6Last update: &b%s UTC\n", formatTime(lastUpdate));
 | 
				
			||||||
			
 | 
								
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -69,8 +69,8 @@ public class Mapper {
 | 
				
			||||||
	 * @return the location in {@code world}
 | 
						 * @return the location in {@code world}
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	public Location coordinatesToLocation(World world, Coordinates coordinates) {
 | 
						public Location coordinatesToLocation(World world, Coordinates coordinates) {
 | 
				
			||||||
		double x = coordinates.longitude * config.scaleLongitude;
 | 
							double x = coordinates.longitude() * config.scaleLongitude;
 | 
				
			||||||
		double z = -coordinates.latitude * config.scaleLatitude;
 | 
							double z = -coordinates.latitude() * config.scaleLatitude;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		return new Location(world, x, 0, z);
 | 
							return new Location(world, x, 0, z);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										34
									
								
								src/main/java/eu/m724/realweather/thunder/StrikeTask.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								src/main/java/eu/m724/realweather/thunder/StrikeTask.java
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,34 @@
 | 
				
			||||||
 | 
					package eu.m724.realweather.thunder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.m724.realweather.DebugLogger;
 | 
				
			||||||
 | 
					import eu.m724.realweather.GlobalConstants;
 | 
				
			||||||
 | 
					import eu.m724.realweather.mapper.Mapper;
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.thunder.TimedStrike;
 | 
				
			||||||
 | 
					import org.bukkit.Location;
 | 
				
			||||||
 | 
					import org.bukkit.scheduler.BukkitRunnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class StrikeTask extends BukkitRunnable {
 | 
				
			||||||
 | 
					    private final Mapper mapper = GlobalConstants.getMapper();
 | 
				
			||||||
 | 
					    private final TimedStrike strike;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public StrikeTask(TimedStrike strike) {
 | 
				
			||||||
 | 
					        this.strike = strike;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void run() {
 | 
				
			||||||
 | 
					        DebugLogger.info("strike: %f %f", 2, strike.coordinates().latitude(), strike.coordinates().longitude());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        mapper.getWorlds().forEach(w -> {
 | 
				
			||||||
 | 
					            Location location = mapper.coordinatesToLocation(w, strike.coordinates());
 | 
				
			||||||
 | 
					            DebugLogger.info("in %s that converts to: %d %d", 2, w.getName(), location.getBlockX(), location.getBlockZ());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // World#isLoaded, Chunk#isLoaded and probably others using Chunk, load the chunk and always return true
 | 
				
			||||||
 | 
					            if (w.isChunkLoaded(location.getBlockX() / 16, location.getBlockZ() / 16)) {
 | 
				
			||||||
 | 
					                location.setY(w.getHighestBlockYAt(location) + 1);
 | 
				
			||||||
 | 
					                w.strikeLightning(location);
 | 
				
			||||||
 | 
					                DebugLogger.info("spawned lightning in %s on y level %d", 2, w.getName(), location.getBlockY());
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,16 +1,21 @@
 | 
				
			||||||
package eu.m724.realweather.thunder;
 | 
					package eu.m724.realweather.thunder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.m724.realweather.Configs;
 | 
					import eu.m724.realweather.Configs;
 | 
				
			||||||
 | 
					import eu.m724.realweather.GlobalConstants;
 | 
				
			||||||
 | 
					import eu.m724.realweather.mapper.Mapper;
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.bukkit.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.m724.realweather.DebugLogger;
 | 
					import eu.m724.realweather.DebugLogger;
 | 
				
			||||||
import eu.m724.wtapi.provider.Providers;
 | 
					import eu.m724.wtapi.provider.Providers;
 | 
				
			||||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.provider.exception.ProviderException;
 | 
					import eu.m724.wtapi.provider.exception.ProviderException;
 | 
				
			||||||
import eu.m724.wtapi.provider.thunder.ThunderProvider;
 | 
					import eu.m724.wtapi.provider.thunder.ThunderProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ThunderMaster {
 | 
					public class ThunderMaster {
 | 
				
			||||||
 | 
						private final Plugin plugin = GlobalConstants.getPlugin();
 | 
				
			||||||
	private final ThunderConfig config = Configs.thunderConfig();
 | 
						private final ThunderConfig config = Configs.thunderConfig();
 | 
				
			||||||
 | 
						private final Mapper mapper = GlobalConstants.getMapper();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	private ThunderProvider provider;
 | 
						private ThunderProvider provider;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	/**
 | 
						/**
 | 
				
			||||||
| 
						 | 
					@ -23,11 +28,11 @@ public class ThunderMaster {
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		provider = Providers.getThunderProvider(config.provider(), null);
 | 
							provider = Providers.getThunderProvider(config.provider(), null);
 | 
				
			||||||
		provider.init();
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        ThunderTask thunderTask = new ThunderTask(provider);
 | 
							provider.registerStrikeConsumer(strike -> new StrikeTask(strike).runTaskLaterAsynchronously(plugin, 0));
 | 
				
			||||||
		thunderTask.init();
 | 
					
 | 
				
			||||||
		thunderTask.runTaskTimer(plugin, 0, config.refreshPeriod());
 | 
							provider.start();
 | 
				
			||||||
 | 
							DebugLogger.info("thunderprovider started", 3);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		DebugLogger.info("thunder loaded", 1);
 | 
							DebugLogger.info("thunder loaded", 1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,57 +0,0 @@
 | 
				
			||||||
package eu.m724.realweather.thunder;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import java.util.ArrayList;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import org.bukkit.Location;
 | 
					 | 
				
			||||||
import org.bukkit.scheduler.BukkitRunnable;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import eu.m724.realweather.DebugLogger;
 | 
					 | 
				
			||||||
import eu.m724.realweather.GlobalConstants;
 | 
					 | 
				
			||||||
import eu.m724.realweather.mapper.Mapper;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.provider.thunder.ThunderProvider;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.provider.thunder.impl.blitzortung.TimedStrike;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class ThunderTask extends BukkitRunnable {
 | 
					 | 
				
			||||||
	private final ThunderProvider thunderProvider;
 | 
					 | 
				
			||||||
	private final Mapper mapper = GlobalConstants.getMapper();
 | 
					 | 
				
			||||||
	private final ArrayList<TimedStrike> strikes = new ArrayList<>();
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public ThunderTask(ThunderProvider thunderProvider) {
 | 
					 | 
				
			||||||
		this.thunderProvider = thunderProvider;
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void init() {
 | 
					 | 
				
			||||||
		thunderProvider.registerStrikeHandler(coords -> {
 | 
					 | 
				
			||||||
			strikes.add(new TimedStrike(System.currentTimeMillis() + thunderProvider.getDelay(), coords));
 | 
					 | 
				
			||||||
		});
 | 
					 | 
				
			||||||
		thunderProvider.start();
 | 
					 | 
				
			||||||
		DebugLogger.info("thunderprovider started", 3);
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public void run() {
 | 
					 | 
				
			||||||
		DebugLogger.info("thundertask running", 3);
 | 
					 | 
				
			||||||
		thunderProvider.tick();
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		while (!strikes.isEmpty()) {
 | 
					 | 
				
			||||||
			TimedStrike strike = strikes.removeFirst();
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			DebugLogger.info("strike: %f %f", 2, strike.coordinates.latitude, strike.coordinates.longitude);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			mapper.getWorlds().forEach(w -> {
 | 
					 | 
				
			||||||
				Location location = mapper.coordinatesToLocation(w, strike.coordinates);
 | 
					 | 
				
			||||||
				DebugLogger.info("in %s that converts to: %d %d", 2, w.getName(), location.getBlockX(), location.getBlockZ());
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				// World#isLoaded, Chunk#isLoaded and probably others using Chunk, load the chunk and always return true
 | 
					 | 
				
			||||||
				if (w.isChunkLoaded(location.getBlockX() / 16, location.getBlockZ() / 16)) {
 | 
					 | 
				
			||||||
					location.setY(w.getHighestBlockYAt(location) + 1);
 | 
					 | 
				
			||||||
					w.strikeLightning(location);
 | 
					 | 
				
			||||||
					DebugLogger.info("spawned lightning in %s on y level %d", 2, w.getName(), location.getBlockY());
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
				
 | 
					 | 
				
			||||||
			});
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					@ -27,7 +27,7 @@ public class AsyncPlayerTimeTask extends BukkitRunnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
 | 
								Coordinates coordinates = mapper.locationToCoordinates(player.getLocation());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			long time = timeConverter.calculateZoneOffset(coordinates.longitude);
 | 
								long time = timeConverter.calculateZoneOffset(coordinates.longitude());
 | 
				
			||||||
			long ticks = timeConverter.millisToTicks(time);
 | 
								long ticks = timeConverter.millisToTicks(time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			player.setPlayerTime(ticks, true);
 | 
								player.setPlayerTime(ticks, true);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -17,7 +17,7 @@ public class SyncTimeUpdateTask extends BukkitRunnable {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	SyncTimeUpdateTask(TimeConverter timeConverter, boolean dynamic) {
 | 
						SyncTimeUpdateTask(TimeConverter timeConverter, boolean dynamic) {
 | 
				
			||||||
		this.timeConverter = timeConverter;
 | 
							this.timeConverter = timeConverter;
 | 
				
			||||||
		this.zoneOffset = !dynamic ? timeConverter.calculateZoneOffset(mapper.getPoint().longitude) : 0;
 | 
							this.zoneOffset = !dynamic ? timeConverter.calculateZoneOffset(mapper.getPoint().longitude()) : 0;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,15 +1,15 @@
 | 
				
			||||||
package eu.m724.realweather.weather;
 | 
					package eu.m724.realweather.weather;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.time.ZoneOffset;
 | 
				
			||||||
import java.util.*;
 | 
					import java.util.*;
 | 
				
			||||||
import java.util.concurrent.CompletableFuture;
 | 
					import java.util.concurrent.CompletableFuture;
 | 
				
			||||||
import java.util.concurrent.CompletionException;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.weather.WeatherQueryResult;
 | 
				
			||||||
import org.bukkit.Server;
 | 
					import org.bukkit.Server;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
import org.bukkit.event.EventHandler;
 | 
					import org.bukkit.event.EventHandler;
 | 
				
			||||||
import org.bukkit.event.Listener;
 | 
					import org.bukkit.event.Listener;
 | 
				
			||||||
import org.bukkit.event.player.PlayerJoinEvent;
 | 
					import org.bukkit.event.player.PlayerJoinEvent;
 | 
				
			||||||
import org.bukkit.event.player.PlayerTeleportEvent;
 | 
					 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.bukkit.plugin.Plugin;
 | 
				
			||||||
import org.bukkit.scheduler.BukkitRunnable;
 | 
					import org.bukkit.scheduler.BukkitRunnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,7 +91,7 @@ public class DynamicWeatherRetriever extends BukkitRunnable implements Listener
 | 
				
			||||||
		if (now > nextUpdate) {
 | 
							if (now > nextUpdate) {
 | 
				
			||||||
			coordinates = makeCoordinates(server.getOnlinePlayers());
 | 
								coordinates = makeCoordinates(server.getOnlinePlayers());
 | 
				
			||||||
			// calculate acceptable request rate based on weather provider quota and active players
 | 
								// calculate acceptable request rate based on weather provider quota and active players
 | 
				
			||||||
			float hourly = weatherProvider.getQuotaHourly() / (float)(weatherProvider.getBulkLimit() * coordinates.coordinatesCount());
 | 
								float hourly = (float) weatherProvider.getQuota().getHourlyQuota() / coordinates.coordinatesCount();
 | 
				
			||||||
			nextUpdate = now + Math.max(60000, (long) (3600000 / hourly));
 | 
								nextUpdate = now + Math.max(60000, (long) (3600000 / hourly));
 | 
				
			||||||
			DebugLogger.info("Next update in %d", 3, nextUpdate);
 | 
								DebugLogger.info("Next update in %d", 3, nextUpdate);
 | 
				
			||||||
		} else { // immediate update for those that need it right now
 | 
							} else { // immediate update for those that need it right now
 | 
				
			||||||
| 
						 | 
					@ -102,16 +102,32 @@ public class DynamicWeatherRetriever extends BukkitRunnable implements Listener
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Coordinates[] coordinatesArray = coordinates.coordinatesPlayersMap().keySet().toArray(Coordinates[]::new);
 | 
							Coordinates[] coordinatesArray = coordinates.coordinatesPlayersMap().keySet().toArray(Coordinates[]::new);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // TODO change to Collection in wtapi? but some ordered kind
 | 
							if (coordinatesArray.length == 0) {
 | 
				
			||||||
        CompletableFuture<Weather[]> weathersFuture =
 | 
								DebugLogger.info("nothing to update, dynamic retriever done", 3);
 | 
				
			||||||
                weatherProvider.getWeatherBulk(coordinatesArray);
 | 
								return;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        CompletableFuture<WeatherQueryResult> weathersFuture =
 | 
				
			||||||
 | 
					                weatherProvider.getWeather(coordinatesArray);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        WeatherQueryResult result = weathersFuture.join();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if (result.exception() != null) {
 | 
				
			||||||
 | 
					            DebugLogger.info("An error occurred trying to retrieve weather data", 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DebugLogger.getDebugLevel() > 0) {
 | 
				
			||||||
 | 
									result.exception().printStackTrace();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Weather[] weathers = result.weathers();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					 | 
				
			||||||
            Weather[] weathers = weathersFuture.join();
 | 
					 | 
				
			||||||
        for (int i=0; i<weathers.length; i++) {
 | 
					        for (int i=0; i<weathers.length; i++) {
 | 
				
			||||||
            Weather weather = weathers[i];
 | 
					            Weather weather = weathers[i];
 | 
				
			||||||
            for (Player player : coordinates.coordinatesPlayersMap().get(coordinatesArray[i])) {
 | 
					            for (Player player : coordinates.coordinatesPlayersMap().get(coordinatesArray[i])) {
 | 
				
			||||||
					playerWeatherCache.put(player, weather, now);
 | 
					                playerWeatherCache.put(player, weather, weather.timestamp().toEpochSecond(ZoneOffset.UTC));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                AsyncWeatherUpdateEvent event =
 | 
					                AsyncWeatherUpdateEvent event =
 | 
				
			||||||
                        new AsyncWeatherUpdateEvent(player, weather);
 | 
					                        new AsyncWeatherUpdateEvent(player, weather);
 | 
				
			||||||
| 
						 | 
					@ -119,12 +135,6 @@ public class DynamicWeatherRetriever extends BukkitRunnable implements Listener
 | 
				
			||||||
                server.getPluginManager().callEvent(event);
 | 
					                server.getPluginManager().callEvent(event);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        } catch (CompletionException e) { // TODO handle finer exceptions
 | 
					 | 
				
			||||||
			DebugLogger.info("An error occurred trying to retrieve weather data", 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (DebugLogger.getDebugLevel() > 0)
 | 
					 | 
				
			||||||
				e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DebugLogger.info("dynamic retriever done", 3);
 | 
					        DebugLogger.info("dynamic retriever done", 3);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,12 +7,10 @@ import eu.m724.realweather.mapper.Mapper;
 | 
				
			||||||
import eu.m724.wtapi.object.Coordinates;
 | 
					import eu.m724.wtapi.object.Coordinates;
 | 
				
			||||||
import eu.m724.wtapi.object.Weather;
 | 
					import eu.m724.wtapi.object.Weather;
 | 
				
			||||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
 | 
					import eu.m724.wtapi.provider.weather.WeatherProvider;
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.weather.WeatherQueryResult;
 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.bukkit.plugin.Plugin;
 | 
				
			||||||
import org.bukkit.scheduler.BukkitRunnable;
 | 
					import org.bukkit.scheduler.BukkitRunnable;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.concurrent.CompletableFuture;
 | 
					 | 
				
			||||||
import java.util.concurrent.CompletionException;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class StaticWeatherRetriever extends BukkitRunnable {
 | 
					public class StaticWeatherRetriever extends BukkitRunnable {
 | 
				
			||||||
    private final Plugin plugin = GlobalConstants.getPlugin();
 | 
					    private final Plugin plugin = GlobalConstants.getPlugin();
 | 
				
			||||||
    private final Mapper mapper = GlobalConstants.getMapper();
 | 
					    private final Mapper mapper = GlobalConstants.getMapper();
 | 
				
			||||||
| 
						 | 
					@ -26,21 +24,24 @@ public class StaticWeatherRetriever extends BukkitRunnable {
 | 
				
			||||||
    @Override
 | 
					    @Override
 | 
				
			||||||
    public void run() {
 | 
					    public void run() {
 | 
				
			||||||
        Coordinates point = mapper.getPoint();
 | 
					        Coordinates point = mapper.getPoint();
 | 
				
			||||||
        CompletableFuture<Weather> weatherFuture = weatherProvider.getWeather(point);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        try {
 | 
					        WeatherQueryResult result = weatherProvider.getWeather(point).join();
 | 
				
			||||||
            Weather weather = weatherFuture.join();
 | 
					
 | 
				
			||||||
 | 
					        if (result.exception() != null) {
 | 
				
			||||||
 | 
					            DebugLogger.info("An error occurred trying to retrieve weather data", 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (DebugLogger.getDebugLevel() > 0)
 | 
				
			||||||
 | 
					                result.exception().printStackTrace();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        Weather weather = result.weathers()[0];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        AsyncWeatherUpdateEvent event =
 | 
					        AsyncWeatherUpdateEvent event =
 | 
				
			||||||
                new AsyncWeatherUpdateEvent(null, weather);
 | 
					                new AsyncWeatherUpdateEvent(null, weather);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        plugin.getServer().getPluginManager().callEvent(event);
 | 
					        plugin.getServer().getPluginManager().callEvent(event);
 | 
				
			||||||
        } catch (CompletionException e) { // TODO handle finer exceptions
 | 
					 | 
				
			||||||
            DebugLogger.info("An error occurred trying to retrieve weather data", 0);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (DebugLogger.getDebugLevel() > 0)
 | 
					 | 
				
			||||||
                e.printStackTrace();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        DebugLogger.info("static weather retriever is done", 3);
 | 
					        DebugLogger.info("static weather retriever is done", 3);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ public class WeatherChanger implements Listener {
 | 
				
			||||||
        if (player != null) { // dynamic mode
 | 
					        if (player != null) { // dynamic mode
 | 
				
			||||||
            DebugLogger.info("Changing weather for player %s", 2, player.getName());
 | 
					            DebugLogger.info("Changing weather for player %s", 2, player.getName());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (weather.isThundering() || weather.isSnowing() || weather.isRaining()) {
 | 
					            if (weather.thundering() || weather.snowing() || weather.raining()) {
 | 
				
			||||||
                player.setPlayerWeather(WeatherType.DOWNFALL);
 | 
					                player.setPlayerWeather(WeatherType.DOWNFALL);
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                player.setPlayerWeather(WeatherType.CLEAR);
 | 
					                player.setPlayerWeather(WeatherType.CLEAR);
 | 
				
			||||||
| 
						 | 
					@ -32,11 +32,11 @@ public class WeatherChanger implements Listener {
 | 
				
			||||||
            DebugLogger.info("Changing weather static", 3);
 | 
					            DebugLogger.info("Changing weather static", 3);
 | 
				
			||||||
            mapper.getWorlds().forEach(w -> {
 | 
					            mapper.getWorlds().forEach(w -> {
 | 
				
			||||||
                DebugLogger.info("Changing weather static in world %s", 2, w.getName());
 | 
					                DebugLogger.info("Changing weather static in world %s", 2, w.getName());
 | 
				
			||||||
                if (weather.isThundering()) {
 | 
					                if (weather.thundering()) {
 | 
				
			||||||
                    w.setClearWeatherDuration(0);
 | 
					                    w.setClearWeatherDuration(0);
 | 
				
			||||||
                    w.setWeatherDuration(120000);
 | 
					                    w.setWeatherDuration(120000);
 | 
				
			||||||
                    w.setThunderDuration(120000);
 | 
					                    w.setThunderDuration(120000);
 | 
				
			||||||
                } else if (weather.isRaining() || weather.isSnowing()) {
 | 
					                } else if (weather.raining() || weather.snowing()) {
 | 
				
			||||||
                    w.setClearWeatherDuration(0);
 | 
					                    w.setClearWeatherDuration(0);
 | 
				
			||||||
                    w.setWeatherDuration(120000);
 | 
					                    w.setWeatherDuration(120000);
 | 
				
			||||||
                    w.setThunderDuration(0);
 | 
					                    w.setThunderDuration(0);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
package eu.m724.realweather.weather;
 | 
					package eu.m724.realweather.weather;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import eu.m724.realweather.Configs;
 | 
					import eu.m724.realweather.Configs;
 | 
				
			||||||
 | 
					import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
				
			||||||
import org.bukkit.GameRule;
 | 
					import org.bukkit.GameRule;
 | 
				
			||||||
import org.bukkit.plugin.Plugin;
 | 
					import org.bukkit.plugin.Plugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -8,7 +9,6 @@ import eu.m724.realweather.DebugLogger;
 | 
				
			||||||
import eu.m724.realweather.GlobalConstants;
 | 
					import eu.m724.realweather.GlobalConstants;
 | 
				
			||||||
import eu.m724.realweather.mapper.Mapper;
 | 
					import eu.m724.realweather.mapper.Mapper;
 | 
				
			||||||
import eu.m724.wtapi.provider.Providers;
 | 
					import eu.m724.wtapi.provider.Providers;
 | 
				
			||||||
import eu.m724.wtapi.provider.exception.NoSuchProviderException;
 | 
					 | 
				
			||||||
import eu.m724.wtapi.provider.exception.ProviderException;
 | 
					import eu.m724.wtapi.provider.exception.ProviderException;
 | 
				
			||||||
import eu.m724.wtapi.provider.weather.WeatherProvider;
 | 
					import eu.m724.wtapi.provider.weather.WeatherProvider;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,7 +32,7 @@ public class WeatherMaster {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (config.dynamic()) {
 | 
							if (config.dynamic()) {
 | 
				
			||||||
			DynamicWeatherRetriever retriever = new DynamicWeatherRetriever(provider);
 | 
								DynamicWeatherRetriever retriever = new DynamicWeatherRetriever(provider);
 | 
				
			||||||
			retriever.runTaskTimerAsynchronously(plugin,0, 1000);
 | 
								retriever.runTaskTimerAsynchronously(plugin,0, 200);
 | 
				
			||||||
			plugin.getServer().getPluginManager().registerEvents(retriever, plugin);
 | 
								plugin.getServer().getPluginManager().registerEvents(retriever, plugin);
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			StaticWeatherRetriever retriever = new StaticWeatherRetriever(provider);
 | 
								StaticWeatherRetriever retriever = new StaticWeatherRetriever(provider);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,10 +9,9 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enabled: false
 | 
					enabled: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Currently only OpenWeatherMap
 | 
					# Currently only OpenMeteo
 | 
				
			||||||
provider: openweathermap
 | 
					provider: openmeteo
 | 
				
			||||||
# put your OpenWeatherMap api key
 | 
					# No API key needed
 | 
				
			||||||
apiKey: REPLACE ME
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# How this plugin affects your world:
 | 
					# How this plugin affects your world:
 | 
				
			||||||
# - static (false): weather is the same across the world
 | 
					# - static (false): weather is the same across the world
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ load: STARTUP
 | 
				
			||||||
main: eu.m724.realweather.RealWeatherPlugin
 | 
					main: eu.m724.realweather.RealWeatherPlugin
 | 
				
			||||||
 | 
					
 | 
				
			||||||
libraries:
 | 
					libraries:
 | 
				
			||||||
- org.java-websocket:Java-WebSocket:1.5.7
 | 
					- org.java-websocket:Java-WebSocket:1.6.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
commands:
 | 
					commands:
 | 
				
			||||||
  rwadmin:
 | 
					  rwadmin:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue