Show any valid address if webserver is enabled (even game servers)

Affects issues:
- Fixed #3251
This commit is contained in:
Aurora Lahtela 2023-10-10 08:40:09 +03:00
parent d6065f497b
commit 549a26bcc8
2 changed files with 14 additions and 4 deletions

View File

@ -105,7 +105,7 @@ public class Addresses {
}
public Optional<String> getProxyServerAddress() {
return dbSystem.getDatabase().query(ServerQueries.fetchProxyServers())
return dbSystem.getDatabase().query(ServerQueries.fetchPlanServerInformationCollection())
.stream()
.map(Server::getWebAddress)
.filter(this::isValidAddress)
@ -113,7 +113,12 @@ public class Addresses {
}
private boolean isValidAddress(String address) {
return address != null && !address.isEmpty() && !"0.0.0.0".equals(address);
return address != null
&& !address.isEmpty()
&& !"0.0.0.0".equals(address)
&& !"https://www.example.address".equals(address)
&& !"http://www.example.address".equals(address)
&& !"http://localhost:0".equals(address);
}
public Optional<String> getServerPropertyIP() {

View File

@ -90,7 +90,7 @@ public class ServerServerInfo extends ServerInfo {
}
private void updateStorage() {
String address = addresses.getAccessAddress().orElseGet(addresses::getFallbackLocalhostAddress);
String address = getAddress();
String name = config.get(PluginSettings.SERVER_NAME);
server.setName(name);
@ -101,6 +101,11 @@ public class ServerServerInfo extends ServerInfo {
fromFile.save(server);
}
private String getAddress() {
return addresses.getAccessAddress()
.orElse(addresses.isWebserverEnabled() ? addresses.getFallbackLocalhostAddress() : null);
}
private Server registerNew() {
return registerNew(generateNewUUID());
}
@ -117,7 +122,7 @@ public class ServerServerInfo extends ServerInfo {
}
private Server createServerObject(ServerUUID serverUUID) {
String webAddress = addresses.getAccessAddress().orElseGet(addresses::getFallbackLocalhostAddress);
String webAddress = getAddress();
String name = config.get(PluginSettings.SERVER_NAME);
return new Server(serverUUID, name, webAddress, currentVersion);
}