Fixes invalid values for 'port' in AddServerPopup
The 'port' value in the `AddServerPopup` can end up invalid due to
whitespaces, such as newline characters (`\n`).
This fix applies `.trim()` to the text to ignore trailing whitespaces.
@@ -60,7 +60,7 @@ public void initialise() {
String name = nameText.getText();
String owner = ownerText.getText();
String address = addressText.getText();
- Integer portBoxed = Ints.tryParse(portText.getText());
+ Integer portBoxed = Ints.tryParse(portText.getText().trim());
int port = (portBoxed != null) ? portBoxed : TerasologyConstants.DEFAULT_PORT;
if (serverInfo == null) {
@@ -87,7 +87,7 @@ public void initialise() {
public Boolean get() {
return !nameText.getText().isEmpty()
&& !addressText.getText().isEmpty()
- && Ints.tryParse(portText.getText()) != null;
+ && Ints.tryParse(portText.getText().trim()) != null;
}
});
