From 943d0d41fbd0a6db2aaa8fe7fae556afdb43cde1 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 22 Dec 2023 11:37:05 -0500 Subject: [PATCH] fix: Fixed an error when starting the plugin for the first time --- .../java/me/xneox/epicguard/core/manager/GeoManager.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/me/xneox/epicguard/core/manager/GeoManager.java b/core/src/main/java/me/xneox/epicguard/core/manager/GeoManager.java index 1a5114aa..e7fb3a67 100644 --- a/core/src/main/java/me/xneox/epicguard/core/manager/GeoManager.java +++ b/core/src/main/java/me/xneox/epicguard/core/manager/GeoManager.java @@ -64,6 +64,9 @@ public GeoManager(EpicGuard epicGuard) { try { if (epicGuard.config().misc().geoDatabaseDownload()) { final String geoIpKey = epicGuard.config().misc().getGeoDatabaseKey(); + if (geoIpKey.isBlank()) { + return; + } this.downloadDatabase( countryDatabase, countryArchive, @@ -75,6 +78,7 @@ public GeoManager(EpicGuard epicGuard) { } else { epicGuard.logger().info("GeoIP database download is disabled, skipping..."); + return; } this.countryReader = new DatabaseReader.Builder(countryDatabase.toFile()).withCache(new CHMCache()).build(); @@ -93,7 +97,7 @@ private void downloadDatabase(@NotNull Path database, @NotNull Path archive, @No this.epicGuard.logger().info("Extracting the database from the tar archive..."); try (var tarInput = new TarArchiveInputStream(new GZIPInputStream(Files.newInputStream(archive)))) { TarArchiveEntry entry; - while ((entry = tarInput.getNextTarEntry()) != null) { + while ((entry = tarInput.getNextEntry()) != null) { // Extracting the database (.mmdb) database we are looking for. if (entry.getName().endsWith(database.getFileName().toString())) { Files.copy(tarInput, database, StandardCopyOption.REPLACE_EXISTING);