Added more in depth information logging to enable exception on first boot if internet access is not available.

This commit is contained in:
Rsl1122 2017-11-10 09:28:50 +02:00
parent d7efc7a04d
commit 209208eb51
3 changed files with 15 additions and 6 deletions

View File

@ -36,6 +36,7 @@ import com.djrapitops.plugin.utilities.Verify;
import main.java.com.djrapitops.plan.api.API;
import main.java.com.djrapitops.plan.api.IPlan;
import main.java.com.djrapitops.plan.api.exceptions.DatabaseInitException;
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
import main.java.com.djrapitops.plan.command.PlanCommand;
import main.java.com.djrapitops.plan.data.additional.HookHandler;
import main.java.com.djrapitops.plan.database.Database;
@ -63,6 +64,7 @@ import org.bukkit.configuration.file.FileConfiguration;
import java.io.File;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -164,7 +166,13 @@ public class Plan extends BukkitPlugin implements IPlan {
Benchmark.start("Enable");
GeolocationCache.checkDB();
try {
GeolocationCache.checkDB();
} catch (UnknownHostException e) {
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
} catch (IOException e) {
throw new PlanEnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
}
new Locale(this).loadLocale();
@ -538,10 +546,10 @@ public class Plan extends BukkitPlugin implements IPlan {
/**
* Method for getting the API.
*
* <p>
* Created due to necessity for testing, but can be used.
* For direct API getter use {@code Plan.getPlanAPI()}.
*
* <p>
* If Plan is reloaded a new API instance is created.
*
* @return Plan API instance.

View File

@ -6,6 +6,7 @@ import com.maxmind.geoip2.DatabaseReader;
import com.maxmind.geoip2.exception.GeoIp2Exception;
import com.maxmind.geoip2.model.CountryResponse;
import com.maxmind.geoip2.record.Country;
import main.java.com.djrapitops.plan.api.exceptions.PlanEnableException;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import java.io.File;
@ -104,13 +105,12 @@ public class GeolocationCache {
/**
* Checks if the DB exists, if not, it downloads it
*
* @throws IOException when an error at download or saving the DB happens
* @throws PlanEnableException when an error at download or saving the DB happens
*/
public static void checkDB() throws IOException {
if (geolocationDB.exists()) {
return;
}
URL downloadSite = new URL("http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz");
try (ReadableByteChannel rbc = Channels.newChannel(new GZIPInputStream(downloadSite.openStream()));
FileOutputStream fos = new FileOutputStream(geolocationDB.getAbsoluteFile())) {

View File

@ -32,7 +32,8 @@ public class ConfigurationWebAPI extends WebAPI {
return badRequest("Called a Bungee Server");
}
if (Settings.BUNGEE_COPY_CONFIG.isFalse() || Settings.BUNGEE_OVERRIDE_STANDALONE_MODE.isTrue()) {
Log.debug("Bungee Config settings overridden on this server.");
Log.info("Bungee Config settings overridden on this server.");
Log.debug(plugin.getMainConfig().getConfigNode("Plugin.Bungee-Override").getChildren().toString());
return success();
}
ServerSpecificSettings.updateSettings((Plan) plugin, variables);