mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 03:27:37 +01:00
Disabled geolocations by default on Sponge
This commit is contained in:
parent
cb9c99108d
commit
2b6564bb32
@ -3,6 +3,8 @@ package com.djrapitops.plan.system.cache;
|
|||||||
import com.djrapitops.plan.api.exceptions.EnableException;
|
import com.djrapitops.plan.api.exceptions.EnableException;
|
||||||
import com.djrapitops.plan.system.SubSystem;
|
import com.djrapitops.plan.system.SubSystem;
|
||||||
import com.djrapitops.plan.system.file.FileSystem;
|
import com.djrapitops.plan.system.file.FileSystem;
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
@ -45,12 +47,14 @@ public class GeolocationCache implements SubSystem {
|
|||||||
@Override
|
@Override
|
||||||
public void enable() throws EnableException {
|
public void enable() throws EnableException {
|
||||||
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
geolocationDB = new File(FileSystem.getDataFolder(), "GeoIP.dat");
|
||||||
try {
|
if (!Check.isSpongeAvailable() || Settings.DATA_GEOLOCATIONS.isTrue()) {
|
||||||
GeolocationCache.checkDB();
|
try {
|
||||||
} catch (UnknownHostException e) {
|
GeolocationCache.checkDB();
|
||||||
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
|
} catch (UnknownHostException e) {
|
||||||
} catch (IOException e) {
|
Log.error("Plan Requires internet access on first run to download GeoLite2 Geolocation database.");
|
||||||
throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
|
} catch (IOException e) {
|
||||||
|
throw new EnableException("Something went wrong saving the downloaded GeoLite2 Geolocation database", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ import com.djrapitops.plan.data.container.GeoInfo;
|
|||||||
import com.djrapitops.plan.system.cache.GeolocationCache;
|
import com.djrapitops.plan.system.cache.GeolocationCache;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
import com.djrapitops.plan.system.processing.CriticalRunnable;
|
||||||
|
import com.djrapitops.plan.system.settings.Settings;
|
||||||
|
import com.djrapitops.plugin.api.Check;
|
||||||
import com.djrapitops.plugin.api.utility.log.Log;
|
import com.djrapitops.plugin.api.utility.log.Log;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -32,11 +34,13 @@ public class IPUpdateProcessor implements CriticalRunnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String country = GeolocationCache.getCountry(ip);
|
if (!Check.isSpongeAvailable() || Settings.DATA_GEOLOCATIONS.isTrue()) {
|
||||||
try {
|
String country = GeolocationCache.getCountry(ip);
|
||||||
Database.getActive().save().geoInfo(uuid, new GeoInfo(ip, country, time));
|
try {
|
||||||
} catch (DBException e) {
|
Database.getActive().save().geoInfo(uuid, new GeoInfo(ip, country, time));
|
||||||
Log.toLog(this.getClass(), e);
|
} catch (DBException e) {
|
||||||
|
Log.toLog(this.getClass(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user