p2
This commit is contained in:
		
					parent
					
						
							
								2cc7701d06
							
						
					
				
			
			
				commit
				
					
						54625a0bf0
					
				
			
		
					 4 changed files with 38 additions and 5 deletions
				
			
		
							
								
								
									
										14
									
								
								src/main/java/pl/minecon724/realweather/ConfigUtils.java
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/main/java/pl/minecon724/realweather/ConfigUtils.java
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | ||||||
|  | package pl.minecon724.realweather; | ||||||
|  | 
 | ||||||
|  | public class ConfigUtils { | ||||||
|  |     public static String parsePlaceholders(String key, String value, Object[] data) { | ||||||
|  |         if (key.equals("messages.actionbarInfo")) { | ||||||
|  |             value = value.replaceAll('%weather_full%', data[0]).replaceAll('%weather%', data[1]); | ||||||
|  |         } | ||||||
|  |         return value; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public static String color(String str) { | ||||||
|  |         return ChatColor.translateAlternateColorCodes('&', str); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -31,6 +31,7 @@ public class GetStateTask extends BukkitRunnable { | ||||||
|     boolean debug, debugDox; |     boolean debug, debugDox; | ||||||
|     double scaleLat, scaleLon; |     double scaleLat, scaleLon; | ||||||
|     int onExceed; |     int onExceed; | ||||||
|  |     boolean actionbar; | ||||||
| 
 | 
 | ||||||
|     MapUtils mapUtils = new MapUtils(); |     MapUtils mapUtils = new MapUtils(); | ||||||
| 
 | 
 | ||||||
|  | @ -41,7 +42,7 @@ public class GetStateTask extends BukkitRunnable { | ||||||
|         WebServiceClient client, boolean broadcast, |         WebServiceClient client, boolean broadcast, | ||||||
|         boolean debug, boolean debugDox, |         boolean debug, boolean debugDox, | ||||||
|         double scaleLat, double scaleLon, |         double scaleLat, double scaleLon, | ||||||
|         int onExceed |         int onExceed, boolean actionbar | ||||||
|     ) { |     ) { | ||||||
|         this.provider = provider; |         this.provider = provider; | ||||||
|         this.source = source; |         this.source = source; | ||||||
|  | @ -56,8 +57,11 @@ public class GetStateTask extends BukkitRunnable { | ||||||
|         this.scaleLat = scaleLat; |         this.scaleLat = scaleLat; | ||||||
|         this.scaleLon = scaleLon; |         this.scaleLon = scaleLon; | ||||||
|         this.onExceed = onExceed; |         this.onExceed = onExceed; | ||||||
|  |         this.actionbar = actionbar; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     // That's a lot of variables | ||||||
|  | 
 | ||||||
|     @Override |     @Override | ||||||
|     public void run() { |     public void run() { | ||||||
|         if (debug) logger.info("Refreshing weather by " + source); |         if (debug) logger.info("Refreshing weather by " + source); | ||||||
|  | @ -70,6 +74,11 @@ public class GetStateTask extends BukkitRunnable { | ||||||
|                 world.setThundering(state.simple == ConditionSimple.THUNDER ? true : false); |                 world.setThundering(state.simple == ConditionSimple.THUNDER ? true : false); | ||||||
|                 world.setStorm(state.simple == ConditionSimple.CLEAR ? false : true); |                 world.setStorm(state.simple == ConditionSimple.CLEAR ? false : true); | ||||||
|             } |             } | ||||||
|  |             if (actionbar) { | ||||||
|  |                 for (Player p : Bukkit.getOnlinePlayers()) { | ||||||
|  | 
 | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } else if (source.equals("player")) { |         } else if (source.equals("player")) { | ||||||
|             InetAddress playerIp = null; |             InetAddress playerIp = null; | ||||||
|             Player curr = null; |             Player curr = null; | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ import org.bukkit.configuration.file.FileConfiguration; | ||||||
| import org.bukkit.plugin.java.JavaPlugin; | import org.bukkit.plugin.java.JavaPlugin; | ||||||
| 
 | 
 | ||||||
| import pl.minecon724.realweather.provider.OpenWeatherMapProvider; | import pl.minecon724.realweather.provider.OpenWeatherMapProvider; | ||||||
| import pl.minecon724.thirdparty.Metrics; | import pl.minecon724.realweather.thirdparty.Metrics; | ||||||
| 
 | 
 | ||||||
| public class RW extends JavaPlugin { | public class RW extends JavaPlugin { | ||||||
| 	FileConfiguration config; | 	FileConfiguration config; | ||||||
|  | @ -54,7 +54,7 @@ public class RW extends JavaPlugin { | ||||||
| 		provider.init(); | 		provider.init(); | ||||||
| 
 | 
 | ||||||
| 		if (source.equals("player")) { | 		if (source.equals("player")) { | ||||||
| 			this.getLogger().info("Initializing GeoLite2 by MaxMind because we need it for retrieving players locations."); | 			this.getLogger().info("Initializing GeoLite2 by MaxMind because we need it for retrieving players real world locations."); | ||||||
| 			int accId = player.getInt("geolite2_accountId"); | 			int accId = player.getInt("geolite2_accountId"); | ||||||
| 			String license = player.getString("geolite2_apiKey"); | 			String license = player.getString("geolite2_apiKey"); | ||||||
| 			client = new WebServiceClient.Builder(accId, license).host("geolite.info").build(); | 			client = new WebServiceClient.Builder(accId, license).host("geolite.info").build(); | ||||||
|  | @ -76,7 +76,10 @@ public class RW extends JavaPlugin { | ||||||
| 			settingsSec.getLong("timeBetweenRecheck") | 			settingsSec.getLong("timeBetweenRecheck") | ||||||
| 		); | 		); | ||||||
| 
 | 
 | ||||||
| 		new Metrics(this, 15020); | 		Metrics metrics = new Metrics(this, 15020); | ||||||
|  | 		metrics.addCustomChart(new SimplePie("source_type", () -> { | ||||||
|  | 			return source; | ||||||
|  | 		})); | ||||||
| 		 | 		 | ||||||
| 		long end = System.currentTimeMillis(); | 		long end = System.currentTimeMillis(); | ||||||
| 		this.getLogger().info( String.format( this.getName() + " enabled! (%s ms)", Long.toString( end-start ) ) ); | 		this.getLogger().info( String.format( this.getName() + " enabled! (%s ms)", Long.toString( end-start ) ) ); | ||||||
|  |  | ||||||
|  | @ -49,8 +49,15 @@ settings: | ||||||
|   timeBetweenRecheck: 600 |   timeBetweenRecheck: 600 | ||||||
|   # Whether to broadcast messages about weather updates |   # Whether to broadcast messages about weather updates | ||||||
|   broadcast: false |   broadcast: false | ||||||
|  |   # Whether to display an actionbar containing info | ||||||
|  |   actionbar: true | ||||||
| 
 | 
 | ||||||
|   # Advanced options |   # Advanced options | ||||||
|   timeBeforeInitialRun: 0 |   timeBeforeInitialRun: 0 | ||||||
|   debug: false |   debug: false | ||||||
|   debugAllowDox: false |   debugAllowDox: false | ||||||
|  | 
 | ||||||
|  | messages: | ||||||
|  |   # %weather_full% - full state description, such as "extreme thunder" | ||||||
|  |   # %weather% - short state description, such as "rain" | ||||||
|  |   actionbarInfo: "&b%weather_full%" | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Minecon724
				Minecon724