tried to fix things
This commit is contained in:
parent
9e24d86140
commit
661df0616b
5 changed files with 92 additions and 15 deletions
|
|
@ -621,10 +621,10 @@ export default function AccessPage({ params }: PageProps) {
|
||||||
|
|
||||||
{needsJavaName && (
|
{needsJavaName && (
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="java-username">Java username</Label>
|
<Label htmlFor="java-username">Java Username</Label>
|
||||||
<Input
|
<Input
|
||||||
id="java-username"
|
id="java-username"
|
||||||
placeholder="Your Java username"
|
placeholder="Your Java Username"
|
||||||
value={javaName}
|
value={javaName}
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
onChange={(event) => setJavaName(event.target.value)}
|
onChange={(event) => setJavaName(event.target.value)}
|
||||||
|
|
@ -637,7 +637,7 @@ export default function AccessPage({ params }: PageProps) {
|
||||||
<Label htmlFor="bedrock-username">Bedrock Gamertag</Label>
|
<Label htmlFor="bedrock-username">Bedrock Gamertag</Label>
|
||||||
<Input
|
<Input
|
||||||
id="bedrock-username"
|
id="bedrock-username"
|
||||||
placeholder="Your Xbox name"
|
placeholder="Your Bedrock Gamertag"
|
||||||
value={bedrockName}
|
value={bedrockName}
|
||||||
className="font-mono"
|
className="font-mono"
|
||||||
onChange={(event) => setBedrockName(event.target.value)}
|
onChange={(event) => setBedrockName(event.target.value)}
|
||||||
|
|
|
||||||
|
|
@ -66,15 +66,31 @@ export async function POST(request: Request) {
|
||||||
|
|
||||||
// Add resolved players to whitelist
|
// Add resolved players to whitelist
|
||||||
for (const player of resolvedPlayers) {
|
for (const player of resolvedPlayers) {
|
||||||
|
// Validate player data before sending to server
|
||||||
|
if (!player || !player.username || !player.platform) {
|
||||||
|
errors.push(`Invalid player data: missing username or platform`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.platform === 'bedrock' && !player.xuid) {
|
||||||
|
errors.push(`Bedrock gamertag player ${player.username} missing XUID - resolution may have failed`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.platform === 'java' && !player.uuid) {
|
||||||
|
errors.push(`Java username player ${player.username} missing UUID - resolution may have failed`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await servertap.addToWhitelist(player);
|
const result = await servertap.addToWhitelist(player);
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
results.push(`Successfully whitelisted ${player.platform} player: ${player.username} (${player.uuid || player.xuid})`);
|
results.push(`Successfully whitelisted ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player: ${player.username} (${player.uuid || player.xuid})`);
|
||||||
} else {
|
} else {
|
||||||
errors.push(`Failed to whitelist ${player.platform} player ${player.username}: ${result.error}`);
|
errors.push(`Failed to whitelist ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player ${player.username}: ${result.error}`);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
errors.push(`Failed to whitelist ${player.platform} player ${player.username}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
errors.push(`Failed to whitelist ${player.platform === 'java' ? 'Java username' : 'Bedrock gamertag'} player ${player.username}: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,18 +107,24 @@ class MinecraftApiClient {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.status === 404) {
|
if (response.status === 404) {
|
||||||
throw new Error('Gamertag not found');
|
throw new Error(`Gamertag "${gamertag}" not found on Xbox Live`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.status === 429) {
|
if (response.status === 429) {
|
||||||
throw new Error('Rate limit exceeded');
|
throw new Error('Xbox Live API rate limit exceeded - please try again later');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`GeyserMC API error: ${response.status}`);
|
throw new Error(`GeyserMC API error: ${response.status} ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const data: GeyserResponse = await response.json();
|
const data: GeyserResponse = await response.json();
|
||||||
|
|
||||||
|
// Validate the response data
|
||||||
|
if (!data.xuid || !data.gamertag) {
|
||||||
|
throw new Error('Invalid response from GeyserMC API - missing XUID or gamertag');
|
||||||
|
}
|
||||||
|
|
||||||
const result: PlayerIdentifierOutput = {
|
const result: PlayerIdentifierOutput = {
|
||||||
platform: 'bedrock',
|
platform: 'bedrock',
|
||||||
username: data.gamertag,
|
username: data.gamertag,
|
||||||
|
|
@ -131,7 +137,10 @@ class MinecraftApiClient {
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`Failed to resolve Bedrock gamertag: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
if (error instanceof Error) {
|
||||||
|
throw new Error(`Failed to resolve Bedrock gamertag "${gamertag}": ${error.message}`);
|
||||||
|
}
|
||||||
|
throw new Error(`Failed to resolve Bedrock gamertag "${gamertag}": Unknown error`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,16 +82,45 @@ class MinecraftClient {
|
||||||
async addToWhitelist(player: string | ResolvedPlayer): Promise<MinecraftResponse<void>> {
|
async addToWhitelist(player: string | ResolvedPlayer): Promise<MinecraftResponse<void>> {
|
||||||
// Handle legacy string input for backward compatibility
|
// Handle legacy string input for backward compatibility
|
||||||
if (typeof player === 'string') {
|
if (typeof player === 'string') {
|
||||||
|
if (!player || player.trim() === '') {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Player name is required'
|
||||||
|
};
|
||||||
|
}
|
||||||
return this.makeRequest("/api/whitelist/add", {
|
return this.makeRequest("/api/whitelist/add", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({ player }),
|
body: JSON.stringify({ player: player.trim() }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Validate resolved player data
|
||||||
|
if (!player || !player.username || !player.platform) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Player data is incomplete: username and platform are required'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate platform-specific identifiers
|
||||||
|
if (player.platform === 'bedrock' && !player.xuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Bedrock gamertag players require an XUID'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.platform === 'java' && !player.uuid) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Java username players require a UUID'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// Send resolved player data with UUID/XUID
|
// Send resolved player data with UUID/XUID
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
player: player.username,
|
player: player.username.trim(),
|
||||||
platform: player.platform,
|
platform: player.platform === 'java' ? 'java username' : 'bedrock gamertag',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (player.uuid) {
|
if (player.uuid) {
|
||||||
|
|
@ -119,8 +148,8 @@ class MinecraftClient {
|
||||||
|
|
||||||
// Send resolved player data with UUID/XUID
|
// Send resolved player data with UUID/XUID
|
||||||
const payload: any = {
|
const payload: any = {
|
||||||
player: player.username,
|
player: player.username.trim(),
|
||||||
platform: player.platform,
|
platform: player.platform === 'java' ? 'java username' : 'bedrock gamertag',
|
||||||
};
|
};
|
||||||
|
|
||||||
if (player.uuid) {
|
if (player.uuid) {
|
||||||
|
|
|
||||||
23
test-platform-names.sh
Normal file
23
test-platform-names.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Test script to verify platform names are sent correctly to server
|
||||||
|
|
||||||
|
echo "Testing platform name mapping..."
|
||||||
|
|
||||||
|
# Test Java player - should send "java username" as platform
|
||||||
|
echo -e "\n=== Java Player Platform Test ==="
|
||||||
|
curl -X POST http://localhost:3000/api/resolve-player \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"type": "java", "username": "Notch"}' \
|
||||||
|
| jq .
|
||||||
|
|
||||||
|
# Test Bedrock player - should send "bedrock gamertag" as platform
|
||||||
|
echo -e "\n=== Bedrock Player Platform Test ==="
|
||||||
|
curl -X POST http://localhost:3000/api/resolve-player \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{"type": "bedrock", "username": "TestGamertag"}' \
|
||||||
|
| jq .
|
||||||
|
|
||||||
|
echo -e "\n=== Platform Mapping Complete ==="
|
||||||
|
echo "Java platform should be: 'java username'"
|
||||||
|
echo "Bedrock platform should be: 'bedrock gamertag'"
|
||||||
Loading…
Add table
Reference in a new issue