Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions HMCL/src/main/java/org/jackhuang/hmcl/ui/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;

import static org.jackhuang.hmcl.setting.ConfigHolder.*;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
import static org.jackhuang.hmcl.setting.ConfigHolder.config;
import static org.jackhuang.hmcl.setting.ConfigHolder.globalConfig;
import static org.jackhuang.hmcl.util.i18n.I18n.i18n;
import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public final class Controllers {
public static final String JAVA_VERSION_TIP = "javaVersion";
Expand Down
4 changes: 3 additions & 1 deletion HMCL/src/main/java/org/jackhuang/hmcl/ui/SVG.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public enum SVG {
SCRIPT("M14,20A2,2 0 0,0 16,18V5H9A1,1 0 0,0 8,6V16H5V5A3,3 0 0,1 8,2H19A3,3 0 0,1 22,5V6H18V18L18,19A3,3 0 0,1 15,22H5A3,3 0 0,1 2,19V18H12A2,2 0 0,0 14,20Z"), // Not Material
SEARCH("M19.6 21 13.3 14.7Q12.55 15.3 11.575 15.65T9.5 16Q6.775 16 4.8875 14.1125T3 9.5Q3 6.775 4.8875 4.8875T9.5 3Q12.225 3 14.1125 4.8875T16 9.5Q16 10.6 15.65 11.575T14.7 13.3L21 19.6 19.6 21ZM9.5 14Q11.375 14 12.6875 12.6875T14 9.5Q14 7.625 12.6875 6.3125T9.5 5Q7.625 5 6.3125 6.3125T5 9.5Q5 11.375 6.3125 12.6875T9.5 14Z"),
SELECT_ALL("M7 17V7H17V17H7ZM9 15H15V9H9V15ZM5 19V21Q4.175 21 3.5875 20.4125T3 19H5ZM3 17V15H5V17H3ZM3 13V11H5V13H3ZM3 9V7H5V9H3ZM5 5H3Q3 4.175 3.5875 3.5875T5 3V5ZM7 21V19H9V21H7ZM7 5V3H9V5H7ZM11 21V19H13V21H11ZM11 5V3H13V5H11ZM15 21V19H17V21H15ZM15 5V3H17V5H15ZM19 21V19H21Q21 19.825 20.4125 20.4125T19 21ZM19 17V15H21V17H19ZM19 13V11H21V13H19ZM19 9V7H21V9H19ZM19 5V3Q19.825 3 20.4125 3.5875T21 5H19Z"),
SERVERS("M 7.5 6 C 7.082031 6 6.730469 6.144531 6.4375 6.4375 C 6.144531 6.730469 6 7.082031 6 7.5 C 6 7.917969 6.144531 8.269531 6.4375 8.5625 C 6.730469 8.855469 7.082031 9 7.5 9 C 7.917969 9 8.269531 8.855469 8.5625 8.5625 C 8.855469 8.269531 9 7.917969 9 7.5 C 9 7.082031 8.855469 6.730469 8.5625 6.4375 C 8.269531 6.144531 7.917969 6 7.5 6 Z M 7.5 16 C 7.082031 16 6.730469 16.144531 6.4375 16.4375 C 6.144531 16.730469 6 17.082031 6 17.5 C 6 17.917969 6.144531 18.269531 6.4375 18.5625 C 6.730469 18.855469 7.082031 19 7.5 19 C 7.917969 19 8.269531 18.855469 8.5625 18.5625 C 8.855469 18.269531 9 17.917969 9 17.5 C 9 17.082031 8.855469 16.730469 8.5625 16.4375 C 8.269531 16.144531 7.917969 16 7.5 16 Z M 4 3 L 20 3 C 20.285156 3 20.519531 3.097656 20.710938 3.289062 C 20.902344 3.480469 21 3.714844 21 4 L 21 11 C 21 11.285156 20.902344 11.519531 20.710938 11.710938 C 20.519531 11.902344 20.285156 12 20 12 L 4 12 C 3.714844 12 3.480469 11.902344 3.289062 11.710938 C 3.097656 11.519531 3 11.285156 3 11 L 3 4 C 3 3.714844 3.097656 3.480469 3.289062 3.289062 C 3.480469 3.097656 3.714844 3 4 3 Z M 5 5 L 5 10 L 19 10 L 19 5 Z M 4 13 L 20 13 C 20.285156 13 20.519531 13.097656 20.710938 13.289062 C 20.902344 13.480469 21 13.714844 21 14 L 21 21 C 21 21.285156 20.902344 21.519531 20.710938 21.710938 C 20.519531 21.902344 20.285156 22 20 22 L 4 22 C 3.714844 22 3.480469 21.902344 3.289062 21.710938 C 3.097656 21.519531 3 21.285156 3 21 L 3 14 C 3 13.714844 3.097656 13.480469 3.289062 13.289062 C 3.480469 13.097656 3.714844 13 4 13 Z M 5 15 L 5 20 L 19 20 L 19 15 Z M 5 5 L 5 10 Z M 5 15 L 5 20 Z M 5 15"),
SERVERS_FILL("M 7.5 6 C 7.082031 6 6.730469 6.144531 6.4375 6.4375 C 6.144531 6.730469 6 7.082031 6 7.5 C 6 7.917969 6.144531 8.269531 6.4375 8.5625 C 6.730469 8.855469 7.082031 9 7.5 9 C 7.917969 9 8.269531 8.855469 8.5625 8.5625 C 8.855469 8.269531 9 7.917969 9 7.5 C 9 7.082031 8.855469 6.730469 8.5625 6.4375 C 8.269531 6.144531 7.917969 6 7.5 6 Z M 7.5 16 C 7.082031 16 6.730469 16.144531 6.4375 16.4375 C 6.144531 16.730469 6 17.082031 6 17.5 C 6 17.917969 6.144531 18.269531 6.4375 18.5625 C 6.730469 18.855469 7.082031 19 7.5 19 C 7.917969 19 8.269531 18.855469 8.5625 18.5625 C 8.855469 18.269531 9 17.917969 9 17.5 C 9 17.082031 8.855469 16.730469 8.5625 16.4375 C 8.269531 16.144531 7.917969 16 7.5 16 Z M 4 3 L 20 3 C 20.285156 3 20.519531 3.097656 20.710938 3.289062 C 20.902344 3.480469 21 3.714844 21 4 L 21 11 C 21 11.285156 20.902344 11.519531 20.710938 11.710938 C 20.519531 11.902344 20.285156 12 20 12 L 4 12 C 3.714844 12 3.480469 11.902344 3.289062 11.710938 C 3.097656 11.519531 3 11.285156 3 11 L 3 4 C 3 3.714844 3.097656 3.480469 3.289062 3.289062 C 3.480469 3.097656 3.714844 3 4 3 Z M 4 13 L 20 13 C 20.285156 13 20.519531 13.097656 20.710938 13.289062 C 20.902344 13.480469 21 13.714844 21 14 L 21 21 C 21 21.285156 20.902344 21.519531 20.710938 21.710938 C 20.519531 21.902344 20.285156 22 20 22 L 4 22 C 3.714844 22 3.480469 21.902344 3.289062 21.710938 C 3.097656 21.519531 3 21.285156 3 21 L 3 14 C 3 13.714844 3.097656 13.480469 3.289062 13.289062 C 3.480469 13.097656 3.714844 13 4 13 Z M 4 13"),
SETTINGS("M19.43 12.98C19.47 12.66 19.5 12.34 19.5 12 19.5 11.66 19.47 11.34 19.43 11.02L21.54 9.37C21.73 9.22 21.78 8.95 21.66 8.73L19.66 5.27C19.57 5.11 19.4 5.02 19.22 5.02 19.16 5.02 19.1 5.03 19.05 5.05L16.56 6.05C16.04 5.65 15.48 5.32 14.87 5.07L14.49 2.42C14.46 2.18 14.25 2 14 2H10C9.75 2 9.54 2.18 9.51 2.42L9.13 5.07C8.52 5.32 7.96 5.66 7.44 6.05L4.95 5.05C4.89 5.03 4.83 5.02 4.77 5.02 4.6 5.02 4.43 5.11 4.34 5.27L2.34 8.73C2.21 8.95 2.27 9.22 2.46 9.37L4.57 11.02C4.53 11.34 4.5 11.67 4.5 12 4.5 12.33 4.53 12.66 4.57 12.98L2.46 14.63C2.27 14.78 2.22 15.05 2.34 15.27L4.34 18.73C4.43 18.89 4.6 18.98 4.78 18.98 4.84 18.98 4.9 18.97 4.95 18.95L7.44 17.95C7.96 18.35 8.52 18.68 9.13 18.93L9.51 21.58C9.54 21.82 9.75 22 10 22H14C14.25 22 14.46 21.82 14.49 21.58L14.87 18.93C15.48 18.68 16.04 18.34 16.56 17.95L19.05 18.95C19.11 18.97 19.17 18.98 19.23 18.98 19.4 18.98 19.57 18.89 19.66 18.73L21.66 15.27C21.78 15.05 21.73 14.78 21.54 14.63L19.43 12.98ZM17.45 11.27C17.49 11.58 17.5 11.79 17.5 12 17.5 12.21 17.48 12.43 17.45 12.73L17.31 13.86 18.2 14.56 19.28 15.4 18.58 16.61 17.31 16.1 16.27 15.68 15.37 16.36C14.94 16.68 14.53 16.92 14.12 17.09L13.06 17.52 12.9 18.65 12.7 20H11.3L11.11 18.65 10.95 17.52 9.89 17.09C9.46 16.91 9.06 16.68 8.66 16.38L7.75 15.68 6.69 16.11 5.42 16.62 4.72 15.41 5.8 14.57 6.69 13.87 6.55 12.74C6.52 12.43 6.5 12.2 6.5 12S6.52 11.57 6.55 11.27L6.69 10.14 5.8 9.44 4.72 8.6 5.42 7.39 6.69 7.9 7.73 8.32 8.63 7.64C9.06 7.32 9.47 7.08 9.88 6.91L10.94 6.48 11.1 5.35 11.3 4H12.69L12.88 5.35 13.04 6.48 14.1 6.91C14.53 7.09 14.93 7.32 15.33 7.62L16.24 8.32 17.3 7.89 18.57 7.38 19.27 8.59 18.2 9.44 17.31 10.14 17.45 11.27ZM12 8C9.79 8 8 9.79 8 12S9.79 16 12 16 16 14.21 16 12 14.21 8 12 8ZM12 14C10.9 14 10 13.1 10 12S10.9 10 12 10 14 10.9 14 12 13.1 14 12 14Z"), // Material Icons
SETTINGS_FILL("M9.25 22l-.4-3.2q-.325-.125-.6125-.3t-.5625-.375L4.7 19.375l-2.75-4.75 2.575-1.95Q4.5 12.5 4.5 12.3375v-.675q0-.1625.025-.3375L1.95 9.375 4.7 4.625l2.975 1.25q.275-.2.575-.375t.6-.3L9.25 2h5.5l.4 3.2q.325.125.6125.3t.5625.375L19.3 4.625l2.75 4.75-2.575 1.95q.025.175.025.3375v.675q0 .1625-.05.3375l2.575 1.95-2.75 4.75-2.95-1.25q-.275.2-.575.375t-.6.3l-.4 3.2H9.25Zm2.8-6.5q1.45 0 2.475-1.025T15.55 12 14.525 9.525 12.05 8.5q-1.475 0-2.4875 1.025T8.55 12q0 1.45 1.0125 2.475T12.05 15.5Z"), // Material Icons
STADIA_CONTROLLER("M4.725 20Q3.225 20 2.1625 18.925T1.05 16.325Q1.05 16.1 1.075 15.875T1.15 15.425L3.25 7.025Q3.6 5.675 4.675 4.8375T7.125 4H16.875Q18.25 4 19.325 4.8375T20.75 7.025L22.85 15.425Q22.9 15.65 22.9375 15.8875T22.975 16.35Q22.975 17.875 21.8875 18.9375T19.275 20Q18.225 20 17.325 19.45T15.975 17.95L15.275 16.5Q15.15 16.25 14.9 16.125T14.375 16H9.625Q9.35 16 9.1 16.125T8.725 16.5L8.025 17.95Q7.575 18.9 6.675 19.45T4.725 20ZM4.8 18Q5.275 18 5.6625 17.75T6.25 17.075L6.95 15.65Q7.325 14.875 8.05 14.4375T9.625 14H14.375Q15.225 14 15.95 14.45T17.075 15.65L17.775 17.075Q17.975 17.5 18.3625 17.75T19.225 18Q19.925 18 20.425 17.5375T20.95 16.375Q20.95 16.4 20.9 15.9L18.8 7.525Q18.625 6.85 18.1 6.425T16.875 6H7.125Q6.425 6 5.8875 6.425T5.2 7.525L3.1 15.9Q3.05 16.05 3.05 16.35 3.05 17.05 3.5625 17.525T4.8 18ZM13.5 11Q13.925 11 14.2125 10.7125T14.5 10Q14.5 9.575 14.2125 9.2875T13.5 9Q13.075 9 12.7875 9.2875T12.5 10Q12.5 10.425 12.7875 10.7125T13.5 11ZM15.5 9Q15.925 9 16.2125 8.7125T16.5 8Q16.5 7.575 16.2125 7.2875T15.5 7Q15.075 7 14.7875 7.2875T14.5 8Q14.5 8.425 14.7875 8.7125T15.5 9ZM15.5 13Q15.925 13 16.2125 12.7125T16.5 12Q16.5 11.575 16.2125 11.2875T15.5 11Q15.075 11 14.7875 11.2875T14.5 12Q14.5 12.425 14.7875 12.7125T15.5 13ZM17.5 11Q17.925 11 18.2125 10.7125T18.5 10Q18.5 9.575 18.2125 9.2875T17.5 9Q17.075 9 16.7875 9.2875T16.5 10Q16.5 10.425 16.7875 10.7125T17.5 11ZM8.5 12.5Q8.825 12.5 9.0375 12.2875T9.25 11.75V10.75H10.25Q10.575 10.75 10.7875 10.5375T11 10Q11 9.675 10.7875 9.4625T10.25 9.25H9.25V8.25Q9.25 7.925 9.0375 7.7125T8.5 7.5Q8.175 7.5 7.9625 7.7125T7.75 8.25V9.25H6.75Q6.425 9.25 6.2125 9.4625T6 10Q6 10.325 6.2125 10.5375T6.75 10.75H7.75V11.75Q7.75 12.075 7.9625 12.2875T8.5 12.5ZM12 12Z"),
Expand All @@ -126,7 +128,7 @@ public enum SVG {
WARNING("M1 21 12 2 23 21H1ZM4.45 19H19.55L12 6 4.45 19ZM12 18Q12.425 18 12.7125 17.7125T13 17Q13 16.575 12.7125 16.2875T12 16Q11.575 16 11.2875 16.2875T11 17Q11 17.425 11.2875 17.7125T12 18ZM11 15H13V10H11V15ZM12 12.5Z"),
WB_SUNNY("M11 4V1H13V4H11ZM11 23V20H13V23H11ZM20 13V11H23V13H20ZM1 13V11H4V13H1ZM18.7 6.7 17.3 5.3 19.05 3.5 20.5 4.95 18.7 6.7ZM4.95 20.5 3.5 19.05 5.3 17.3 6.7 18.7 4.95 20.5ZM19.05 20.5 17.3 18.7 18.7 17.3 20.5 19.05 19.05 20.5ZM5.3 6.7 3.5 4.95 4.95 3.5 6.7 5.3 5.3 6.7ZM12 18Q9.5 18 7.75 16.25T6 12Q6 9.5 7.75 7.75T12 6Q14.5 6 16.25 7.75T18 12Q18 14.5 16.25 16.25T12 18ZM12 16Q13.675 16 14.8375 14.8375T16 12Q16 10.325 14.8375 9.1625T12 8Q10.325 8 9.1625 9.1625T8 12Q8 13.675 9.1625 14.8375T12 16ZM12 12Z"),
WB_SUNNY_FILL("M11 4V1h2V4H11Zm0 19V20h2v3H11Zm9-10V11h3v2H20ZM1 13V11H4v2H1ZM18.7 6.7 17.3 5.3l1.75-1.8L20.5 4.95 18.7 6.7ZM4.95 20.5 3.5 19.05 5.3 17.3l1.4 1.4-1.75 1.8Zm14.1 0-1.75-1.8 1.4-1.4 1.8 1.75-1.45 1.45ZM5.3 6.7 3.5 4.95 4.95 3.5 6.7 5.3 5.3 6.7ZM12 18q-2.5 0-4.25-1.75T6 12 7.75 7.75 12 6t4.25 1.75T18 12t-1.75 4.25T12 18Z"),
;
;

public static final double DEFAULT_SIZE = 24;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.jackhuang.hmcl.ui.construct.*;
import org.jackhuang.hmcl.ui.decorator.DecoratorAnimatedPage;
import org.jackhuang.hmcl.ui.decorator.DecoratorPage;
import org.jackhuang.hmcl.ui.versions.server.ServerListPage;
import org.jackhuang.hmcl.util.io.FileUtils;

import java.util.Optional;
Expand All @@ -56,6 +57,7 @@ public class VersionPage extends DecoratorAnimatedPage implements DecoratorPage
private final TabHeader.Tab<ModListPage> modListTab = new TabHeader.Tab<>("modListTab");
private final TabHeader.Tab<WorldListPage> worldListTab = new TabHeader.Tab<>("worldList");
private final TabHeader.Tab<SchematicsPage> schematicsTab = new TabHeader.Tab<>("schematicsTab");
private final TabHeader.Tab<ServerListPage> serverListTab = new TabHeader.Tab<>("serverListTab");
private final TabHeader.Tab<ResourcepackListPage> resourcePackTab = new TabHeader.Tab<>("resourcePackTab");
private final TransitionPane transitionPane = new TransitionPane();
private final BooleanProperty currentVersionUpgradable = new SimpleBooleanProperty();
Expand All @@ -71,8 +73,9 @@ public VersionPage() {
resourcePackTab.setNodeSupplier(loadVersionFor(ResourcepackListPage::new));
worldListTab.setNodeSupplier(loadVersionFor(WorldListPage::new));
schematicsTab.setNodeSupplier(loadVersionFor(SchematicsPage::new));
serverListTab.setNodeSupplier(loadVersionFor(ServerListPage::new));

tab = new TabHeader(transitionPane, versionSettingsTab, installerListTab, modListTab, resourcePackTab, worldListTab, schematicsTab);
tab = new TabHeader(transitionPane, versionSettingsTab, installerListTab, modListTab, resourcePackTab, worldListTab, schematicsTab, serverListTab);
tab.select(versionSettingsTab);

addEventHandler(Navigator.NavigationEvent.NAVIGATED, this::onNavigated);
Expand Down Expand Up @@ -138,6 +141,8 @@ public void loadVersion(String version, Profile profile) {
worldListTab.getNode().loadVersion(profile, version);
if (schematicsTab.isInitialized())
schematicsTab.getNode().loadVersion(profile, version);
if (serverListTab.isInitialized())
serverListTab.getNode().loadVersion(profile, version);
currentVersionUpgradable.set(profile.getRepository().isModpack(version));
}

Expand Down Expand Up @@ -244,7 +249,8 @@ protected Skin(VersionPage control) {
.addNavigationDrawerTab(control.tab, control.modListTab, i18n("mods.manage"), SVG.EXTENSION, SVG.EXTENSION_FILL)
.addNavigationDrawerTab(control.tab, control.resourcePackTab, i18n("resourcepack.manage"), SVG.TEXTURE)
.addNavigationDrawerTab(control.tab, control.worldListTab, i18n("world.manage"), SVG.PUBLIC)
.addNavigationDrawerTab(control.tab, control.schematicsTab, i18n("schematics.manage"), SVG.SCHEMA, SVG.SCHEMA_FILL);
.addNavigationDrawerTab(control.tab, control.schematicsTab, i18n("schematics.manage"), SVG.SCHEMA, SVG.SCHEMA_FILL)
.addNavigationDrawerTab(control.tab, control.serverListTab, i18n("servers.manage"), SVG.SERVERS, SVG.SERVERS_FILL);
VBox.setVgrow(sideBar, Priority.ALWAYS);

PopupMenu browseList = new PopupMenu();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2025 huangyuhui <[email protected]> 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 <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.ui.versions.server;

import com.github.steveice10.opennbt.tag.builtin.ByteTag;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import com.github.steveice10.opennbt.tag.builtin.StringTag;
import javafx.scene.image.Image;
import org.jackhuang.hmcl.ui.image.ImageUtils;
import org.jackhuang.hmcl.util.Lazy;

import java.io.ByteArrayInputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import static org.jackhuang.hmcl.util.logging.Logger.LOG;

public final class ServerData {
final boolean acceptTextures;
final boolean hidden;
final String icon;
final String ip;
final String name;

final Lazy<Image> iconImage;

public ServerData(
boolean acceptTextures,
boolean hidden,
String icon,
String ip,
String name
) {
this.acceptTextures = acceptTextures;
this.hidden = hidden;
this.icon = icon;
this.ip = ip;
this.name = name;

this.iconImage = new Lazy<>(() -> parseImage(icon));
}

public static ServerData fromStorage(Map<Object, Object> storage) {
return new ServerData(
Boolean.TRUE.equals(storage.get("acceptTextures")),
Boolean.TRUE.equals(storage.get("hidden")),
storage.get("icon") instanceof String s ? s : null,
storage.get("ip") instanceof String s ? s : null,
storage.get("name") instanceof String s ? s : null
);
}

public static ServerData fromCompoundTag(CompoundTag tag) {
return new ServerData(
tag.get("acceptTextures") instanceof ByteTag bt && bt.getValue() != 0,
tag.get("hidden") instanceof ByteTag bt && bt.getValue() != 0,
tag.get("icon") instanceof StringTag st ? st.getValue() : null,
tag.get("ip") instanceof StringTag st ? st.getValue() : null,
tag.get("name") instanceof StringTag st ? st.getValue() : null
);
}

public static Image parseImage(String imageBase64String) {
if (imageBase64String == null || imageBase64String.isEmpty()) {
return null;
}
try (ByteArrayInputStream bais = new ByteArrayInputStream(Base64.getDecoder().decode(imageBase64String))) {
// png format.
return ImageUtils.DEFAULT.load(bais, 0, 0, true, true);
} catch (Exception e) {
LOG.warning("Failed to decode server icon", e);
return null;
}
}

public static ServerData createServerData(String name, String ip) {
return new ServerData(false, false, null, ip, name);
}

public void writeToCompoundTag(CompoundTag tag) {
tag.put(new ByteTag("acceptTextures", (byte) (acceptTextures ? 1 : 0)));
tag.put(new ByteTag("hidden", (byte) (hidden ? 1 : 0)));
if (icon != null) tag.put(new StringTag("icon", icon));
if (ip != null) tag.put(new StringTag("ip", ip));
if (name != null) tag.put(new StringTag("name", name));
}

public Map<Object, Object> toSerializeMap() {
Map<Object, Object> map = new HashMap<>();
map.put("acceptTextures", acceptTextures);
if (icon != null) map.put("icon", icon);
if (ip != null) map.put("ip", ip);
if (name != null) map.put("name", name);
return map;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
ServerData that = (ServerData) o;
return Objects.equals(ip, that.ip) && Objects.equals(name, that.name);
}

@Override
public int hashCode() {
return Objects.hash(ip, name);
}

@Override
public String toString() {
return "ServerData[" +
"acceptTextures=" + acceptTextures + ", " +
"hidden=" + hidden + ", " +
"icon=" + icon + ", " +
"ip=" + ip + ", " +
"name=" + name + ']';
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Hello Minecraft! Launcher
* Copyright (C) 2025 huangyuhui <[email protected]> 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 <https://www.gnu.org/licenses/>.
*/
package org.jackhuang.hmcl.ui.versions.server;

import org.jackhuang.hmcl.setting.Profile;

import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class ServerDataHolder {
final Profile profile;
final Path serverDatPath;
final int inDatPathSlot;

final List<String> holdInstances = new ArrayList<>();
final ServerData serverData;

public ServerDataHolder(Profile profile, Path serverDatPath, int inDatPathSlot, final ServerData serverData) {
this.profile = profile;
this.serverDatPath = serverDatPath;
this.inDatPathSlot = inDatPathSlot;
this.serverData = serverData;
}

@Override
public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false;
ServerDataHolder that = (ServerDataHolder) o;
return inDatPathSlot == that.inDatPathSlot && Objects.equals(profile, that.profile) && Objects.equals(serverDatPath, that.serverDatPath);
}

@Override
public int hashCode() {
return Objects.hash(profile, serverDatPath, inDatPathSlot);
}
}
Loading