This commit is contained in:
Minecon724 2022-06-11 09:26:53 +00:00
parent 2cc7701d06
commit 54625a0bf0
4 changed files with 38 additions and 5 deletions

View 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);
}
}

View file

@ -31,6 +31,7 @@ public class GetStateTask extends BukkitRunnable {
boolean debug, debugDox;
double scaleLat, scaleLon;
int onExceed;
boolean actionbar;
MapUtils mapUtils = new MapUtils();
@ -41,7 +42,7 @@ public class GetStateTask extends BukkitRunnable {
WebServiceClient client, boolean broadcast,
boolean debug, boolean debugDox,
double scaleLat, double scaleLon,
int onExceed
int onExceed, boolean actionbar
) {
this.provider = provider;
this.source = source;
@ -56,8 +57,11 @@ public class GetStateTask extends BukkitRunnable {
this.scaleLat = scaleLat;
this.scaleLon = scaleLon;
this.onExceed = onExceed;
this.actionbar = actionbar;
}
// That's a lot of variables
@Override
public void run() {
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.setStorm(state.simple == ConditionSimple.CLEAR ? false : true);
}
if (actionbar) {
for (Player p : Bukkit.getOnlinePlayers()) {
}
}
} else if (source.equals("player")) {
InetAddress playerIp = null;
Player curr = null;

View file

@ -10,7 +10,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import pl.minecon724.realweather.provider.OpenWeatherMapProvider;
import pl.minecon724.thirdparty.Metrics;
import pl.minecon724.realweather.thirdparty.Metrics;
public class RW extends JavaPlugin {
FileConfiguration config;
@ -54,7 +54,7 @@ public class RW extends JavaPlugin {
provider.init();
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");
String license = player.getString("geolite2_apiKey");
client = new WebServiceClient.Builder(accId, license).host("geolite.info").build();
@ -76,7 +76,10 @@ public class RW extends JavaPlugin {
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();
this.getLogger().info( String.format( this.getName() + " enabled! (%s ms)", Long.toString( end-start ) ) );

View file

@ -49,8 +49,15 @@ settings:
timeBetweenRecheck: 600
# Whether to broadcast messages about weather updates
broadcast: false
# Whether to display an actionbar containing info
actionbar: true
# Advanced options
timeBeforeInitialRun: 0
debug: false
debugAllowDox: false
messages:
# %weather_full% - full state description, such as "extreme thunder"
# %weather% - short state description, such as "rain"
actionbarInfo: "&b%weather_full%"