mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
ServerList: show server brand, when running an unknown version, bug fixes
This commit is contained in:
parent
c7246956f4
commit
ff4445d6b9
@ -29,10 +29,6 @@ public class ServerListPing {
|
||||
return raw.getAsJsonObject("version").get("protocol").getAsInt();
|
||||
}
|
||||
|
||||
public String getServerBrand() {
|
||||
return raw.getAsJsonObject("version").get("name").getAsString();
|
||||
}
|
||||
|
||||
public int getPlayerOnline() {
|
||||
return raw.getAsJsonObject("players").get("online").getAsInt();
|
||||
}
|
||||
@ -63,4 +59,12 @@ public class ServerListPing {
|
||||
public JsonObject getRaw() {
|
||||
return this.raw;
|
||||
}
|
||||
|
||||
public String getServerVersion() {
|
||||
return raw.getAsJsonObject("version").get("name").getAsString();
|
||||
}
|
||||
|
||||
public boolean isForgeServer() {
|
||||
return raw.has("modinfo") && raw.getAsJsonObject("modinfo").has("type") && raw.getAsJsonObject("modinfo").get("type").getAsString().equals("FML");
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,6 @@ public class TextComponent {
|
||||
}
|
||||
buffer.append(object.get("text").getAsString());
|
||||
}
|
||||
buffer.append(ChatAttributes.RESET);
|
||||
return buffer.toString();
|
||||
}
|
||||
return "";
|
||||
|
@ -98,4 +98,9 @@ public class Server {
|
||||
Minosoft.getConfig().putServer(this);
|
||||
Minosoft.getConfig().saveToFile(Config.configFileName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName() + " (" + getAddress() + ")";
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@ -94,8 +95,8 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
}
|
||||
icon.setImage(favicon);
|
||||
|
||||
Connection c = new Connection(server.getId(), server.getAddress(), new Player(Minosoft.accountList.get(0)));
|
||||
c.addPingCallback(ping -> Platform.runLater(() -> {
|
||||
Connection connection = new Connection(server.getId(), server.getAddress(), new Player(Minosoft.accountList.get(0)));
|
||||
connection.addPingCallback(ping -> Platform.runLater(() -> {
|
||||
if (ping == null) {
|
||||
// Offline
|
||||
players.setText("");
|
||||
@ -106,7 +107,9 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
players.setText(String.format("%d/%d", ping.getPlayerOnline(), ping.getMaxPlayers()));
|
||||
Version serverVersion = Versions.getVersionById(ping.getProtocolNumber());
|
||||
if (serverVersion == null) {
|
||||
version.setText(String.format("UNKNOWN(%d)", ping.getProtocolNumber()));
|
||||
version.setText(ping.getServerVersion());
|
||||
version.setTextFill(Color.RED);
|
||||
optionsConnect.setDisable(true);
|
||||
} else {
|
||||
version.setText(serverVersion.getVersionName());
|
||||
}
|
||||
@ -117,7 +120,7 @@ public class ServerListCell extends ListCell<Server> implements Initializable {
|
||||
icon.setImage(ping.getFavicon());
|
||||
}
|
||||
}));
|
||||
c.resolve(ConnectionReasons.PING); // resolve dns address and connect
|
||||
connection.resolve(ConnectionReasons.PING); // resolve dns address and connect
|
||||
}
|
||||
this.model = server;
|
||||
}
|
||||
|
@ -184,14 +184,16 @@ public class Connection {
|
||||
|
||||
public void setVersion(Version version) {
|
||||
this.version = version;
|
||||
try {
|
||||
Versions.loadVersionMappings(version.getProtocolVersion());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.fatal(String.format("Could not load mapping for %s. Exiting...", version));
|
||||
System.exit(1);
|
||||
if (reason == ConnectionReasons.GET_VERSION) {
|
||||
try {
|
||||
Versions.loadVersionMappings(version.getProtocolVersion());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.fatal(String.format("Could not load mapping for %s. Exiting...", version));
|
||||
System.exit(1);
|
||||
}
|
||||
customMapping.setVersion(version);
|
||||
}
|
||||
customMapping.setVersion(version);
|
||||
}
|
||||
|
||||
public PacketHandler getHandler() {
|
||||
|
@ -63,8 +63,7 @@ public class PacketHandler {
|
||||
}
|
||||
version = Versions.getVersionById(versionId);
|
||||
if (version == null) {
|
||||
Log.fatal(String.format("Server is running on unknown version or a invalid version was forced (version=%d). Disconnecting...", versionId));
|
||||
connection.disconnect();
|
||||
Log.fatal(String.format("Server is running on unknown version or a invalid version was forced (version=%d, brand=\"%s\")", versionId, pkg.getResponse().getServerVersion()));
|
||||
} else {
|
||||
connection.setVersion(version);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user