mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2025-12-20 15:29:20 +00:00
Don't return null if the player link option fails to load
This commit is contained in:
@@ -42,6 +42,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import org.geysermc.floodgate.api.link.PlayerLink;
|
import org.geysermc.floodgate.api.link.PlayerLink;
|
||||||
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
import org.geysermc.floodgate.api.logger.FloodgateLogger;
|
||||||
@@ -61,6 +62,7 @@ public final class PlayerLinkLoader {
|
|||||||
@Named("dataDirectory")
|
@Named("dataDirectory")
|
||||||
private Path dataDirectory;
|
private Path dataDirectory;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public PlayerLink load() {
|
public PlayerLink load() {
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
throw new IllegalStateException("Config cannot be null!");
|
throw new IllegalStateException("Config cannot be null!");
|
||||||
@@ -78,7 +80,7 @@ public final class PlayerLinkLoader {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} catch (IOException exception) {
|
} catch (IOException exception) {
|
||||||
logger.error("Failed to list possible database implementations", exception);
|
logger.error("Failed to list possible database implementations", exception);
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can skip the rest if global linking is enabled and no database implementations has been
|
// we can skip the rest if global linking is enabled and no database implementations has been
|
||||||
@@ -89,7 +91,7 @@ public final class PlayerLinkLoader {
|
|||||||
|
|
||||||
if (files.isEmpty()) {
|
if (files.isEmpty()) {
|
||||||
logger.error("Failed to find a database implementation");
|
logger.error("Failed to find a database implementation");
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
}
|
}
|
||||||
|
|
||||||
Path implementationPath = files.get(0);
|
Path implementationPath = files.get(0);
|
||||||
@@ -110,14 +112,14 @@ public final class PlayerLinkLoader {
|
|||||||
|
|
||||||
if (!found) {
|
if (!found) {
|
||||||
logger.error("Failed to find an implementation for type: {}", lConfig.getType());
|
logger.error("Failed to find an implementation for type: {}", lConfig.getType());
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String name = implementationPath.getFileName().toString();
|
String name = implementationPath.getFileName().toString();
|
||||||
if (!Utils.isValidDatabaseName(name)) {
|
if (!Utils.isValidDatabaseName(name)) {
|
||||||
logger.error("Found database {} but the name doesn't match {}",
|
logger.error("Found database {} but the name doesn't match {}",
|
||||||
name, Constants.DATABASE_NAME_FORMAT);
|
name, Constants.DATABASE_NAME_FORMAT);
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
}
|
}
|
||||||
int firstSplit = name.indexOf('-') + 1;
|
int firstSplit = name.indexOf('-') + 1;
|
||||||
databaseName = name.substring(firstSplit, name.indexOf('-', firstSplit));
|
databaseName = name.substring(firstSplit, name.indexOf('-', firstSplit));
|
||||||
@@ -186,14 +188,14 @@ public final class PlayerLinkLoader {
|
|||||||
} catch (ClassCastException exception) {
|
} catch (ClassCastException exception) {
|
||||||
logger.error("The database implementation ({}) doesn't extend the PlayerLink class!",
|
logger.error("The database implementation ({}) doesn't extend the PlayerLink class!",
|
||||||
implementationPath.getFileName().toString(), exception);
|
implementationPath.getFileName().toString(), exception);
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
if (init) {
|
if (init) {
|
||||||
logger.error("Error while initialising database jar", exception);
|
logger.error("Error while initialising database jar", exception);
|
||||||
} else {
|
} else {
|
||||||
logger.error("Error while loading database jar", exception);
|
logger.error("Error while loading database jar", exception);
|
||||||
}
|
}
|
||||||
return null;
|
return new DisabledPlayerLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user