Prevented unregistered player export

Error was reported on Discord that exporting on join sometimes
caused a BadRequestException

A check was added to prevent exporting non-registered players.
This commit is contained in:
Rsl1122 2019-10-19 13:56:04 +03:00
parent 2c714fe4e9
commit d17a962505
2 changed files with 4 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package com.djrapitops.plan.delivery.export;
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.Database;
import com.djrapitops.plan.storage.database.queries.PlayerFetchQueries;
import javax.inject.Inject;
import javax.inject.Singleton;
@ -49,6 +50,7 @@ public class PlayerJSONExporter extends FileExporter {
public void export(Path toDirectory, UUID playerUUID, String playerName) throws IOException {
Database.State dbState = dbSystem.getDatabase().getState();
if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return;
if (!dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))) return;
Path to = toDirectory.resolve("player/" + toFileName(playerName) + ".json");
exportJSON(to, playerUUID);

View File

@ -29,6 +29,7 @@ import com.djrapitops.plan.settings.locale.Locale;
import com.djrapitops.plan.settings.theme.Theme;
import com.djrapitops.plan.storage.database.DBSystem;
import com.djrapitops.plan.storage.database.Database;
import com.djrapitops.plan.storage.database.queries.PlayerFetchQueries;
import com.djrapitops.plan.storage.file.PlanFiles;
import com.djrapitops.plan.storage.file.Resource;
import org.apache.commons.lang3.StringUtils;
@ -79,6 +80,7 @@ public class PlayerPageExporter extends FileExporter {
public void export(Path toDirectory, UUID playerUUID, String playerName) throws IOException, NotFoundException, ParseException {
Database.State dbState = dbSystem.getDatabase().getState();
if (dbState == Database.State.CLOSED || dbState == Database.State.CLOSING) return;
if (!dbSystem.getDatabase().query(PlayerFetchQueries.isPlayerRegistered(playerUUID))) return;
exportPaths.put("../network", toRelativePathFromRoot("network"));
exportPaths.put("../server", toRelativePathFromRoot("server"));