Skip to content
This repository was archived by the owner on Nov 26, 2019. It is now read-only.
This repository was archived by the owner on Nov 26, 2019. It is now read-only.

The favourites tab needs to be hooked to the USERDATA.dat file #45

@IstuntmanI

Description

@IstuntmanI

So it will be easier to handle the favourites. It should use the same favourites list as the samp.exe browser. Looks like you already did most of the work for this, but for some reason you forgot to finish it.

Also:

public static SampServer addServerToFavourites(final String address, final Integer port) {
final SampServer server = new SampServer(address, port);
try (final SampQuery query = new SampQuery(server.getAddress(), server.getPort()))
{
query.getBasicServerInfo().ifPresent(serverInfo -> {
server.setPlayers(Integer.parseInt(serverInfo[1]));
server.setMaxPlayers(Integer.parseInt(serverInfo[2]));
server.setHostname(serverInfo[3]);
server.setMode(serverInfo[4]);
server.setLanguage(serverInfo[5]);
});
query.getServersRules().ifPresent(rules -> {
server.setWebsite(rules.get("weburl"));
server.setVersion(rules.get("version"));
});
}
catch (final SocketException | UnknownHostException exception) {
Logging.warn("Error updating server information.", exception);
server.setHostname(UNKNOWN);
server.setLanguage(UNKNOWN);
server.setMode(UNKNOWN);
server.setWebsite(UNKNOWN);
server.setVersion(UNKNOWN);
server.setLagcomp(UNKNOWN);
server.setPlayers(0);
server.setMaxPlayers(0);
}
Logging.info("Adding server to favourites: " + server);
addServerToFavourites(server);
return server;
}

It looks like you should just return without actually calling addServerToFavourites(server); if that exception is caught. If I'm not missing anything.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions