本文介绍了一些visual visual basic java对visual basic的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试将此java代码转换为visual basic。我不确定这是否可行,但如果有人有任何线索那么它会帮助我很多。或者,如果你知道另一种方法来做到这一点。这是一个Minecraft发射器。这是登录。

Hello, I'm trying to convert this java code to visual basic. I'm not sure if this is possible but if anyone has any clue then It will help me a lot. Or if you know another way to do this. And this is for a Minecraft launcher. This is to login.

private void attemptLogin(Map<String, String> argMap)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(argMap.get("username"));
    auth.setPassword(argMap.get("password"));
    argMap.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    argMap.put("accessToken", auth.getAuthenticatedToken());
    argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    argMap.put("username", auth.getSelectedProfile().getName());
    argMap.put("userType", auth.getUserType().getName());

    // 1.8 only apperantly.. -_-
    argMap.put("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
 


public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}


public static String login(String email, String password)
{
	YggdrasilAuthenticationService authenticationService =
		new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
	YggdrasilUserAuthentication authentication =
		(YggdrasilUserAuthentication)authenticationService
			.createUserAuthentication(Agent.MINECRAFT);
	authentication.setUsername(email);
	authentication.setPassword(password);
	String displayText;
	try
	{
		authentication.logIn();
		Minecraft.getMinecraft().session =
			new Session(authentication.getSelectedProfile().getName(),
				authentication.getSelectedProfile().getId().toString(),
				authentication.getAuthenticatedToken(), "mojang");
		displayText = "";
	}catch(AuthenticationUnavailableException e)
	{
		displayText = "4lCannot contact authentication server!";
	}catch(AuthenticationException e)
	{// wrong password account migrated
		if(e.getMessage().contains("Invalid username or password.")
			|| e.getMessage().toLowerCase().contains("account migrated"))
			displayText = "4lWrong password!";
		else
			displayText = "4lCannot contact authentication server!";
		logger.error(e.getMessage());
	}catch(NullPointerException e)
	{
		displayText = "4lWrong password!";
	}
	return displayText;
}


public static String check(String email, String password)
{
	YggdrasilAuthenticationService authenticationService =
		new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
	YggdrasilUserAuthentication authentication =
		(YggdrasilUserAuthentication)authenticationService
			.createUserAuthentication(Agent.MINECRAFT);
	authentication.setUsername(email);
	authentication.setPassword(password);
	String displayText;
	try
	{
		authentication.logIn();
		displayText = "";
	}catch(AuthenticationUnavailableException e)
	{
		displayText = "4lCannot contact authentication server!";
	}catch(AuthenticationException e)
	{// wrong password account migrated
		if(e.getMessage().contains("Invalid username or password.")
			|| e.getMessage().toLowerCase().contains("account migrated"))
			displayText = "4lWrong password!";
		else
			displayText = "4lCannot contact authentication server!";
		logger.error(e.getMessage());
	}catch(NullPointerException e)
	{
		displayText = "4lWrong password!";
	}
	return displayText;
}




还有很多例子
HERE
。¥


非常感谢你!


There is a lot more examples HERE.

Thank you so much!

推荐答案

如果您的问题与语法有关,那么您可以在此处进行转换:
$

If your problem concerns the syntax, then you can do the conversion here:
http://www.carlosag.net/tools/codetranslator/

如果问题与对象和逻辑有关,你可能会在我的论坛中获得更好的帮助。

If the problem is related to the objects and logic, you will probably get better assistance in a minecraft forum.


这篇关于一些visual visual basic java对visual basic的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 05:15