-
Notifications
You must be signed in to change notification settings - Fork 53
feat(instance): add&delete game server through SJMCL #1328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
e39e07e
3f649f5
3d7e3b5
26e1e57
20c84cb
562116f
b056628
360e573
1ee4c2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,11 +246,13 @@ pub struct ScreenshotInfo { | |
| pub enum InstanceError { | ||
| InstanceNotFoundByID, | ||
| ServerNbtReadError, | ||
| DuplicateServer, | ||
| FileNotFoundError, | ||
| InvalidSourcePath, | ||
| FileCreationFailed, | ||
| FileCopyFailed, | ||
| FileMoveFailed, | ||
| FileOperationError, | ||
|
Comment on lines
+249
to
+255
|
||
| FolderCreationFailed, | ||
| ShortcutCreationFailed, | ||
| ZipFileProcessFailed, | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,172 @@ | ||||||
| import { | ||||||
| Button, | ||||||
| FormControl, | ||||||
| FormErrorMessage, | ||||||
| FormLabel, | ||||||
| Input, | ||||||
| Modal, | ||||||
| ModalBody, | ||||||
| ModalCloseButton, | ||||||
| ModalContent, | ||||||
| ModalFooter, | ||||||
| ModalHeader, | ||||||
| ModalOverlay, | ||||||
| ModalProps, | ||||||
| VStack, | ||||||
| } from "@chakra-ui/react"; | ||||||
| import { useCallback, useEffect, useRef, useState } from "react"; | ||||||
| import { useTranslation } from "react-i18next"; | ||||||
| import { useLauncherConfig } from "@/contexts/config"; | ||||||
| import { useToast } from "@/contexts/toast"; | ||||||
| import { InstanceService } from "@/services/instance"; | ||||||
|
|
||||||
| interface AddGameServerModalProps extends Omit<ModalProps, "children"> { | ||||||
| presetUrl?: string; | ||||||
| instanceId: string; | ||||||
| } | ||||||
|
|
||||||
| const AddGameServerModal: React.FC<AddGameServerModalProps> = ({ | ||||||
| presetUrl = "", | ||||||
| instanceId, | ||||||
| ...modalProps | ||||||
| }) => { | ||||||
| const { t } = useTranslation(); | ||||||
| const toast = useToast(); | ||||||
| const { config } = useLauncherConfig(); | ||||||
| const primaryColor = config.appearance.theme.primaryColor; | ||||||
| const { isOpen, onClose } = modalProps; | ||||||
| const initialRef = useRef(null); | ||||||
| const hasAutoPresetRef = useRef(false); | ||||||
|
|
||||||
| const [serverUrl, setServerUrl] = useState<string>(""); | ||||||
| const [serverName, setServerName] = useState<string>(""); | ||||||
| const [isLoading, setIsLoading] = useState<boolean>(false); | ||||||
|
|
||||||
| const [isServerUrlTouched, setIsServerUrlTouched] = useState(false); | ||||||
| const isServerUrlInvalid = isServerUrlTouched && !serverUrl; | ||||||
| const serverNamePlaceholder = t("AddGameServerModal.placeholder.serverName"); | ||||||
|
|
||||||
| useEffect(() => { | ||||||
| if (isOpen) { | ||||||
| hasAutoPresetRef.current = false; | ||||||
| setServerUrl(presetUrl); | ||||||
| setServerName(""); | ||||||
| setIsServerUrlTouched(false); | ||||||
| } | ||||||
| }, [isOpen, presetUrl]); | ||||||
|
|
||||||
| const handleAddGameServer = useCallback( | ||||||
| (instanceId: string) => { | ||||||
| const finalServerName = serverName.trim() || serverNamePlaceholder; | ||||||
| setIsLoading(true); | ||||||
| InstanceService.addGameServer(instanceId, serverUrl, finalServerName) | ||||||
|
||||||
| InstanceService.addGameServer(instanceId, serverUrl, finalServerName) | |
| InstanceService.addGameServer(instanceId, serverUrl.trim(), finalServerName) |
Outdated
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
Copilot
AI
Feb 22, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The input type "url" is semantically incorrect for Minecraft server addresses. These addresses are typically in the format "example.com" or "example.com:25565", which are not valid URLs (they lack a protocol like http:// or https://). Using type="url" may cause browser validation issues and confuse users.
Change the input type to "text" to properly accept Minecraft server address formats.
| type="url" | |
| type="text" |
This comment was marked as resolved.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.