Fixed Realms handling issues

This commit is contained in:
RaphiMC 2024-04-29 17:40:25 +02:00
parent 35acb36d1c
commit 1b009561c2
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 31 additions and 4 deletions

View File

@ -91,7 +91,7 @@ dependencies {
include("net.raphimc.netminecraft:all:2.4.0") {
exclude group: "com.google.code.gson", module: "gson"
}
include("net.raphimc:MinecraftAuth:4.0.0") {
include("net.raphimc:MinecraftAuth:4.0.1-SNAPSHOT") {
exclude group: "com.google.code.gson", module: "gson"
exclude group: "org.slf4j", module: "slf4j-api"
}

View File

@ -37,6 +37,7 @@ import net.raphimc.viaproxy.saves.impl.accounts.MicrosoftAccount;
import net.raphimc.viaproxy.ui.I18n;
import net.raphimc.viaproxy.ui.UITab;
import net.raphimc.viaproxy.ui.ViaProxyWindow;
import net.raphimc.viaproxy.util.StringUtil;
import net.raphimc.viaproxy.util.logging.Logger;
import javax.swing.*;
@ -205,12 +206,12 @@ public class RealmsTab extends UITab {
panel.setBorder(BorderFactory.createLineBorder(UIManager.getColor("Table.gridColor")));
String nameString = "";
if (!world.getOwnerName().isEmpty()) nameString += world.getOwnerName() + " - ";
if (world.getOwnerName() != null) nameString += world.getOwnerName() + " - ";
String versionString = "";
if (!world.getActiveVersion().isEmpty()) versionString += " - " + world.getActiveVersion();
GBC.create(panel).grid(0, 0).weightx(1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL).add(new JLabel(nameString + world.getName() + " (" + world.getState() + ")"));
GBC.create(panel).grid(0, 0).weightx(1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL).add(new JLabel(nameString + StringUtil.emptyIfNull(world.getName()) + " (" + world.getState() + ")"));
GBC.create(panel).grid(1, 0).insets(5, 5, 0, 5).anchor(GBC.LINE_END).add(new JLabel(world.getWorldType() + versionString));
GBC.create(panel).grid(0, 1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL).add(new JLabel(world.getMotd()));
GBC.create(panel).grid(0, 1).insets(5, 5, 0, 5).fill(GBC.HORIZONTAL).add(new JLabel(StringUtil.emptyIfNull(world.getMotd())));
final JButton join = new JButton(I18n.get("tab.realms.join"));
if (world.isExpired()) {
join.setEnabled(false);

View File

@ -0,0 +1,26 @@
/*
* This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy
* Copyright (C) 2021-2024 RK_01/RaphiMC and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package net.raphimc.viaproxy.util;
public class StringUtil {
public static String emptyIfNull(final String s) {
return s == null ? "" : s;
}
}