Skip to content

Commit 99bf00c

Browse files
Copilotci010
andcommitted
Allow quickPlayMultiplayer and server options to work together for compatibility
Co-authored-by: ci010 <[email protected]>
1 parent d8715f5 commit 99bf00c

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

packages/core/README.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,15 @@ const proc = launch({
103103
});
104104
```
105105

106-
**Note:** When both `quickPlayMultiplayer` and `server` options are provided, `quickPlayMultiplayer` takes precedence.
106+
Both `quickPlayMultiplayer` and `server` options can be used together for compatibility:
107+
108+
```ts
109+
// Both options together for compatibility
110+
const proc = launch({
111+
gamePath,
112+
javaPath,
113+
version,
114+
quickPlayMultiplayer: 'play.hypixel.net:25565',
115+
server: { ip: 'play.hypixel.net', port: 25565 }
116+
});
117+
```

packages/core/launch.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ describe('Launcher', () => {
290290
expect(args.indexOf('--server')).toBe(-1)
291291
expect(args.indexOf('--port')).toBe(-1)
292292
})
293-
test('should prefer quickPlayMultiplayer over server option', async ({ mock }) => {
293+
test('should allow both quickPlayMultiplayer and server options for compatibility', async ({ mock }) => {
294294
const server = {
295295
ip: '192.168.1.1',
296296
port: 25565,
@@ -303,9 +303,9 @@ describe('Launcher', () => {
303303
quickPlayMultiplayer: '127.0.0.1:25565',
304304
})
305305
expect(args[args.indexOf('--quickPlayMultiplayer') + 1]).toEqual('127.0.0.1:25565')
306-
// Should not contain old server arguments when quickPlayMultiplayer is present
307-
expect(args.indexOf('--server')).toBe(-1)
308-
expect(args.indexOf('--port')).toBe(-1)
306+
// Should also contain legacy server arguments for compatibility
307+
expect(args[args.indexOf('--server') + 1]).toEqual('192.168.1.1')
308+
expect(args[args.indexOf('--port') + 1]).toEqual('25565')
309309
})
310310
})
311311

packages/core/launch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,8 @@ export async function generateArguments(options: LaunchOption) {
812812
}
813813
if (options.quickPlayMultiplayer) {
814814
cmd.push('--quickPlayMultiplayer', options.quickPlayMultiplayer)
815-
} else if (options.server) {
815+
}
816+
if (options.server) {
816817
cmd.push('--server', options.server.ip)
817818
if (options.server.port) {
818819
cmd.push('--port', options.server.port.toString())

0 commit comments

Comments
 (0)