Question

So i am trying to make a minecraft launcher but it won't log in to server's because my account is migrated to Mojang so i log in with my email instead of my username but there is a way to get my username so i have found out how but i need to get a string of code from this text using c#.

"134382:deprecated:USERNAME:7a909de0530c310c69c:dba0c48a038a66bb98"

I need to get the "deprecated:USERNAME" into a separate text box, how would i go about doing this, note i am coding in c# and to get the code above i use this code.

http://login.minecraft.net/?user=USERNAME&password=PASSWORD&version=15

this is the code so far

private void PlayBtn_Click(object sender, EventArgs e)
    {
        string username = UsernameBox.Text;
        string password = PasswordBox.Text;
        Process proc = new Process();
        startMinecraft(true, 256, 1024, username, username, false);
    }
    public static void startMinecraft(bool mode, int ramMin, int ramMax, string username, string sessionID, bool debug)
    {
        string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\";
        string appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\";
        Process proc = new Process();
        if (debug == true)
        {
            proc.StartInfo.FileName = "java";
        }
        else
        {
            proc.StartInfo.FileName = "javaw";
        }

        //Online and offline modes
        if (mode == true)
        {
            proc.StartInfo.Arguments = "-Xms" + ramMin + "M -Xmx" + ramMax + "M -Djava.library.path=" + appData + ".minecraft/bin/natives -cp " + appData + ".minecraft/bin/minecraft.jar;" + appData + ".minecraft/bin/jinput.jar;" + appData + ".minecraft/bin/lwjgl.jar;" + appData + ".minecraft/bin/lwjgl_util.jar net.minecraft.client.Minecraft " + username + " " + sessionID;
        }
        else
        {
            proc.StartInfo.Arguments = "-Xms" + ramMin + "M -Xmx" + ramMax + "M -Djava.library.path=" + appData + ".minecraft/bin/natives -cp " + appData + ".minecraft/bin/minecraft.jar;" + appData + ".minecraft/bin/jinput.jar;" + appData + ".minecraft/bin/lwjgl.jar;" + appData + ".minecraft/bin/lwjgl_util.jar net.minecraft.client.Minecraft " + username;
        }
        proc.Start();
    }
Was it helpful?

Solution

if the order remains the same, you can try this

  string[] results = yourstring.split(':');
  yourtextbox.Text = results[1]+ ":" + results[2];   //results1 will give depreciated and results 2 will give UsErname

OTHER TIPS

You haven't fully specified the format of the source string. For now, I"ll assume it's of the form

*:deprecated:USERNAME:*:*

where * is arbitrary but contains no :.

Then you can say:

var fields = source.Split(':');
string target = fields[1] + ":" + fields[2];

and now you can assign target to your textbox.

This is a working code i needed :) thanks so much for the help.

WebClient client = new WebClient();
        String htmlCode = client.DownloadString("http://login.minecraft.net/?user=USERNAME&password=PASSWORD&version=15");
        label1.Text = htmlCode;
        string[] results = htmlCode.Split(':');
        label2.Text = results[1] + ":" + results[2];
        label3.Text = results[2];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top