mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-07-21 17:57:07 +00:00
fix(lceonline): client not opening & webview window for lceonline login (#129)
This commit is contained in:
parent
124bbad12c
commit
e8038f3c3e
|
|
@ -66,7 +66,7 @@ LCE Emerald Launcher is the easiest way to play Minecraft Legacy Console Edition
|
|||
| **Controller Support** | Full gamepad navigation support (keyboard support included) |
|
||||
| **Discord Rich Presence** | Show your current activity and game status on Discord |
|
||||
| **Workshop** | Community content like DLCs, Textures, Skins and more |
|
||||
| **Free Multiplayer** | Powered by LCELive, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
|
||||
| **Free Multiplayer** | Powered by LCEOnline, Emerald provides a free multiplayer service so you can play with anyone without port forwarding! |
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -183,7 +183,7 @@ sudo apt install --reinstall libwebkit2gtk-4.1-0
|
|||
- **The Emerald Team** - Technical development and maintenance
|
||||
- **4J Studios & Mojang** - Original creators of Legacy Console Edition
|
||||
- **The LCE Community** - Research and foundations for LCE on PC
|
||||
- **Veroxsity (Racoon)** - Original creator of LCELive
|
||||
- **Str1k3r** - Original creator of LCEOnline
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"core:resources:default",
|
||||
"core:tray:default",
|
||||
"core:webview:default",
|
||||
"core:webview:allow-create-webview-window",
|
||||
"core:window:default",
|
||||
"core:window:allow-set-decorations",
|
||||
"core:window:allow-is-fullscreen",
|
||||
|
|
|
|||
|
|
@ -27,9 +27,9 @@ pub async fn launch_game(
|
|||
perform_instance_sync(&app, &instance_id).await?;
|
||||
let working_dir = util::get_instance_working_dir(&app, &instance_id);
|
||||
let config_val = config::load_config_raw(app.clone());
|
||||
let lce_live = McServer { name: "LCELive Game".into(), ip: "127.0.0.1".into(), port: 61000 };
|
||||
if !servers.iter().any(|s| s.ip == lce_live.ip && s.port == lce_live.port) {
|
||||
servers.push(lce_live);
|
||||
let lce_online = McServer { name: "LCEOnline Game".into(), ip: "127.0.0.1".into(), port: 61000 };
|
||||
if !servers.iter().any(|s| s.ip == lce_online.ip && s.port == lce_online.port) {
|
||||
servers.push(lce_online);
|
||||
}
|
||||
if let Some(ref saved) = config_val.saved_servers {
|
||||
for s in saved {
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ export default function ChooseInstanceModal({
|
|||
selectedInstance,
|
||||
[
|
||||
{
|
||||
name: invite.hostName || "LCE Online Game",
|
||||
name: invite.hostName || "LCEOnline Game",
|
||||
ip: "127.0.0.1",
|
||||
port: 61000,
|
||||
},
|
||||
|
|
@ -87,7 +87,7 @@ export default function ChooseInstanceModal({
|
|||
await TauriService.stopAllProxies();
|
||||
await TauriService.launchGame(selectedInstance, [
|
||||
{
|
||||
name: invite.hostName || "LCE Online Game",
|
||||
name: invite.hostName || "LCEOnline Game",
|
||||
ip: invite.hostIp,
|
||||
port: invite.hostPort,
|
||||
},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import {
|
|||
import ChooseInstanceModal from "../modals/ChooseInstanceModal";
|
||||
import { lceOnlineService } from "../../services/LceOnlineService";
|
||||
import { TauriService } from "../../services/TauriService";
|
||||
import { WebviewWindow } from '@tauri-apps/api/webviewWindow';
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
interface LceOnlineViewProps {
|
||||
addFriendTarget?: string | null;
|
||||
onClearAddFriendTarget?: () => void;
|
||||
|
|
@ -28,6 +30,7 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||
const { playPressSound, playBackSound } = useAudio();
|
||||
const game = useGame();
|
||||
const [isSignedIn, setIsSignedIn] = useState(lceOnlineService.signedIn);
|
||||
const opened = useRef(false);
|
||||
const [currentTab, setCurrentTab] = useState<
|
||||
"friends" | "requests" | "invites"
|
||||
>("friends");
|
||||
|
|
@ -73,12 +76,29 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isSignedIn) {
|
||||
TauriService.openUrl(
|
||||
"https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
|
||||
);
|
||||
}
|
||||
}, []);
|
||||
if (isSignedIn) return;
|
||||
|
||||
if (!opened.current) {
|
||||
opened.current = true;
|
||||
new WebviewWindow('LCEOnline', {
|
||||
url: "https://mclegacyedition.xyz/internal/auth?appId=emerald_launcher",
|
||||
width: 400,
|
||||
height: 570,
|
||||
resizable: false,
|
||||
title: 'Emerald Legacy Launcher - LCEOnline',
|
||||
});
|
||||
};
|
||||
|
||||
const unlisten = listen<string[]>('deep-link', async (event) => {
|
||||
const authUrl = event.payload.find(u => u.startsWith('emerald://'));
|
||||
if (!authUrl) return;
|
||||
const token = new URL(authUrl).searchParams.get('token');
|
||||
if (token) setIsSignedIn(true);
|
||||
(await WebviewWindow.getByLabel('LCEOnline'))?.close();
|
||||
});
|
||||
|
||||
return () => { unlisten.then(f => f()); };
|
||||
}, [isSignedIn]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!addFriendTarget) return;
|
||||
|
|
@ -619,7 +639,15 @@ const LceOnlineView = memo(function LceOnlineView({
|
|||
>
|
||||
{renderContent()}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex justify-center pt-4 pb-2">
|
||||
<img
|
||||
src="/images/lceonline.png"
|
||||
alt="LCEOnline"
|
||||
className="h-5 opacity-70 cursor-pointer"
|
||||
onClick={() => TauriService.openUrl("https://mclegacyedition.xyz/")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AnimatePresence>
|
||||
{isAddingFriend && (
|
||||
|
|
|
|||
|
|
@ -497,7 +497,7 @@ export function useGameManager({
|
|||
profile,
|
||||
PARTNERSHIP_SERVERS,
|
||||
currentEdition?.lceOnline
|
||||
? extraLaunchArgs!.concat([
|
||||
? (extraLaunchArgs ?? []).concat([
|
||||
"-token",
|
||||
localStorage.getItem("lceonline_session")
|
||||
? JSON.parse(localStorage.getItem("lceonline_session")!).accessToken
|
||||
|
|
|
|||
|
|
@ -1,17 +1,9 @@
|
|||
import { useState, useEffect, useRef } from "react";
|
||||
import { lceOnlineService } from "../services/LceOnlineService";
|
||||
export function useLceOnlineNotifications() {
|
||||
const [friendRequestMessage, setFriendRequestMessage] = useState<
|
||||
string | null
|
||||
>(null);
|
||||
const [friendRequestMessage, setFriendRequestMessage] = useState<string | null>(null);
|
||||
const [InviteMessage, setInviteMessage] = useState<string | null>(null);
|
||||
const [invites, setInvites] = useState<
|
||||
Array<{
|
||||
inviteid: string;
|
||||
from: { uuid: string; username: string };
|
||||
sessionid: string;
|
||||
}>
|
||||
>([]);
|
||||
const [invites, setInvites] = useState<Array<{ inviteid: string; from: { uuid: string; username: string; }; sessionid: string; }>>([]);
|
||||
const seenRequests = useRef<Set<string>>(new Set());
|
||||
const seenInvites = useRef<Set<string>>(new Set());
|
||||
useEffect(() => {
|
||||
|
|
@ -24,7 +16,7 @@ export function useLceOnlineNotifications() {
|
|||
lists.requests.forEach((r: string) => {
|
||||
if (!seenRequests.current.has(r)) {
|
||||
seenRequests.current.add(r);
|
||||
setFriendRequestMessage(`New Friend request from ${r}`);
|
||||
setFriendRequestMessage(`${r} wants to be friends!`);
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
|
|
@ -32,12 +24,12 @@ export function useLceOnlineNotifications() {
|
|||
const invitesData = await lceOnlineService.getInvites();
|
||||
setInvites(invitesData);
|
||||
invitesData.forEach((i) => {
|
||||
if (!seenInvites.current.has(i.inviteid)) {
|
||||
seenInvites.current.add(i.inviteid);
|
||||
setInviteMessage(`New invite from ${i.from.username}`);
|
||||
}
|
||||
});
|
||||
} catch {}
|
||||
if (!seenInvites.current.has(i.inviteid)) {
|
||||
seenInvites.current.add(i.inviteid);
|
||||
setInviteMessage(`${i.from.username} invited you to play!`);
|
||||
}
|
||||
});
|
||||
} catch { }
|
||||
};
|
||||
|
||||
const init = async () => {
|
||||
|
|
@ -47,7 +39,7 @@ export function useLceOnlineNotifications() {
|
|||
lists.requests.forEach((r: string) => {
|
||||
if (!seenRequests.current.has(r)) {
|
||||
seenRequests.current.add(r);
|
||||
setFriendRequestMessage(`New Friend request from ${r}`);
|
||||
setFriendRequestMessage(`${r} wants to be friends!`);
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
|
|
@ -55,12 +47,12 @@ export function useLceOnlineNotifications() {
|
|||
const invitesData = await lceOnlineService.getInvites();
|
||||
setInvites(invitesData);
|
||||
invitesData.forEach((i) => {
|
||||
if (!seenInvites.current.has(i.inviteid)) {
|
||||
seenInvites.current.add(i.inviteid);
|
||||
setInviteMessage(`New invite from ${i.from.username}`);
|
||||
}
|
||||
});
|
||||
} catch {}
|
||||
if (!seenInvites.current.has(i.inviteid)) {
|
||||
seenInvites.current.add(i.inviteid);
|
||||
setInviteMessage(`${i.from.username} invited you to play!`);
|
||||
}
|
||||
});
|
||||
} catch { }
|
||||
}
|
||||
pollInterval = setInterval(poll, 3000);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue