diff --git a/src/app/access/[method]/[step]/page.tsx b/src/app/access/[method]/[step]/page.tsx
index b2c340c..9a4749f 100644
--- a/src/app/access/[method]/[step]/page.tsx
+++ b/src/app/access/[method]/[step]/page.tsx
@@ -621,10 +621,10 @@ export default function AccessPage({ params }: PageProps) {
{needsJavaName && (
-
+
setJavaName(event.target.value)}
@@ -637,7 +637,7 @@ export default function AccessPage({ params }: PageProps) {
setBedrockName(event.target.value)}
diff --git a/src/app/api/whitelist/route.ts b/src/app/api/whitelist/route.ts
index d3e1fc1..7d1cc4e 100644
--- a/src/app/api/whitelist/route.ts
+++ b/src/app/api/whitelist/route.ts
@@ -66,15 +66,31 @@ export async function POST(request: Request) {
// Add resolved players to whitelist
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 {
const result = await servertap.addToWhitelist(player);
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 {
- 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) {
- 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'}`);
}
}
diff --git a/src/lib/minecraft-api.ts b/src/lib/minecraft-api.ts
index e7bc212..c119267 100644
--- a/src/lib/minecraft-api.ts
+++ b/src/lib/minecraft-api.ts
@@ -107,18 +107,24 @@ class MinecraftApiClient {
});
if (response.status === 404) {
- throw new Error('Gamertag not found');
+ throw new Error(`Gamertag "${gamertag}" not found on Xbox Live`);
}
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) {
- throw new Error(`GeyserMC API error: ${response.status}`);
+ throw new Error(`GeyserMC API error: ${response.status} ${response.statusText}`);
}
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 = {
platform: 'bedrock',
username: data.gamertag,
@@ -131,7 +137,10 @@ class MinecraftApiClient {
return result;
} 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`);
}
}
diff --git a/src/lib/servertap.ts b/src/lib/servertap.ts
index 8a22600..e73ea6e 100644
--- a/src/lib/servertap.ts
+++ b/src/lib/servertap.ts
@@ -82,16 +82,45 @@ class MinecraftClient {
async addToWhitelist(player: string | ResolvedPlayer): Promise> {
// Handle legacy string input for backward compatibility
if (typeof player === 'string') {
+ if (!player || player.trim() === '') {
+ return {
+ success: false,
+ error: 'Player name is required'
+ };
+ }
return this.makeRequest("/api/whitelist/add", {
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
const payload: any = {
- player: player.username,
- platform: player.platform,
+ player: player.username.trim(),
+ platform: player.platform === 'java' ? 'java username' : 'bedrock gamertag',
};
if (player.uuid) {
@@ -119,8 +148,8 @@ class MinecraftClient {
// Send resolved player data with UUID/XUID
const payload: any = {
- player: player.username,
- platform: player.platform,
+ player: player.username.trim(),
+ platform: player.platform === 'java' ? 'java username' : 'bedrock gamertag',
};
if (player.uuid) {
diff --git a/test-platform-names.sh b/test-platform-names.sh
new file mode 100644
index 0000000..e3c3925
--- /dev/null
+++ b/test-platform-names.sh
@@ -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'"