From 68d0aa96889d411f32ea95d51360ac0ed0c35257 Mon Sep 17 00:00:00 2001 From: pop4959 Date: Tue, 4 Aug 2020 08:22:14 -0700 Subject: [PATCH] Improve GeoIP errors/warnings (#3568) Aims to provide a better and less confusing error for users of GeoIP who have not configured properly (which is more common now after the license key requirement). Seems like a lot of people miss the initial error on startup, and so this may help a bit. Closes #3561. --- Essentials/src/messages.properties | 3 ++- .../essentials/geoip/EssentialsGeoIPPlayerListener.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index 0965cdabe..d4d99ce72 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -238,7 +238,8 @@ getposCommandUsage=/ [player] giveCommandDescription=Give a player an item. giveCommandUsage=/ [amount [itemmeta...]] geoipCantFind=\u00a76Player \u00a7c{0} \u00a76comes from \u00a7aan unknown country\u00a76. -geoIpLicenseMissing=No license key found! Please visit https://essentialsx.cf/geoip for first time setup instructions. +geoIpErrorOnJoin=Unable to fetch GeoIP data for {0}. Please ensure that your license key and configuration are correct. +geoIpLicenseMissing=No license key found\! Please visit https\://essentialsx.net/geoip for first time setup instructions. geoIpUrlEmpty=GeoIP download url is empty. geoIpUrlInvalid=GeoIP download url is invalid. givenSkull=\u00a76You have been given the skull of \u00a7c{0}\u00a76. diff --git a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java index a7850b96d..b969cbf8b 100644 --- a/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java +++ b/EssentialsGeoIP/src/com/earth2me/essentials/geoip/EssentialsGeoIPPlayerListener.java @@ -56,6 +56,10 @@ public class EssentialsGeoIPPlayerListener implements Listener, IConf { InetAddress address = player.getAddress().getAddress(); StringBuilder sb = new StringBuilder(); + if (mmreader == null) { + logger.log(Level.WARNING, tl("geoIpErrorOnJoin", u.getName())); + return; + } try { if (config.getBoolean("database.show-cities", false)) {