mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Improve session caching
- Change SessionCache.db to SessionCache.ini Allows users to view and edit session cache - Automatically import previous SessionCache.db But this file is only read, not updated - Automatically import Minecraft session If you are logged in in Minecraft, no need to login again This is only done if Disk session cache is enabled See #232 and #430 for more information - Disk session cache becomes default The feature is no longer experimental and now recommended as the Mojang login servers now have a severe rate limit Previous default was Memory session cache, not saved to disk
This commit is contained in:
parent
a37e340613
commit
18fd24d2d5
5 changed files with 155 additions and 32 deletions
|
|
@ -1,4 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace MinecraftClient.Protocol
|
||||
{
|
||||
|
|
@ -17,5 +19,35 @@ namespace MinecraftClient.Protocol
|
|||
PlayerID = String.Empty;
|
||||
ClientID = String.Empty;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Join(",", ID, PlayerName, PlayerID, ClientID);
|
||||
}
|
||||
|
||||
public static SessionToken FromString(string tokenString)
|
||||
{
|
||||
string[] fields = tokenString.Split(',');
|
||||
if (fields.Length < 4)
|
||||
throw new InvalidDataException("Invalid string format");
|
||||
|
||||
SessionToken session = new SessionToken();
|
||||
session.ID = fields[0];
|
||||
session.PlayerName = fields[1];
|
||||
session.PlayerID = fields[2];
|
||||
session.ClientID = fields[3];
|
||||
|
||||
Guid temp;
|
||||
if (!Guid.TryParseExact(session.ID, "N", out temp))
|
||||
throw new InvalidDataException("Invalid session ID");
|
||||
if (!ChatBot.IsValidName(session.PlayerName))
|
||||
throw new InvalidDataException("Invalid player name");
|
||||
if (!Guid.TryParseExact(session.PlayerID, "N", out temp))
|
||||
throw new InvalidDataException("Invalid player ID");
|
||||
if (!Guid.TryParseExact(session.ClientID, "N", out temp))
|
||||
throw new InvalidDataException("Invalid client ID");
|
||||
|
||||
return session;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue