本文整理汇总了Java中com.mojang.authlib.UserAuthentication类的典型用法代码示例。如果您正苦于以下问题:Java UserAuthentication类的具体用法?Java UserAuthentication怎么用?Java UserAuthentication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserAuthentication类属于com.mojang.authlib包,在下文中一共展示了UserAuthentication类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.mojang.authlib.UserAuthentication; //导入依赖的package包/类
/**
* Attempts to login with the specified username and password.
* If the login is successful then a session will be created. If
* not, {@code null} will be returned
*
* @return A valid session, if able to login, otherwise {@code null}
*/
@Override
public Session build() {
UserAuthentication auth = new YggdrasilAuthenticationService(this.proxy, "").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(this.username);
auth.setPassword(this.password);
try {
auth.logIn();
} catch (AuthenticationException e) {
return null;
}
GameProfile profile = auth.getSelectedProfile();
return new Session(profile.getName(), profile.getId().toString(), auth.getAuthenticatedToken(), "MOJANG");
}
示例2: getUserAuthentication
import com.mojang.authlib.UserAuthentication; //导入依赖的package包/类
@Override
public UserAuthentication getUserAuthentication() {
return this.userAuthentication;
}
示例3: createUserAuthentication
import com.mojang.authlib.UserAuthentication; //导入依赖的package包/类
public UserAuthentication createUserAuthentication(Proxy proxy) {
return new YggdrasilAuthenticationService(
proxy,
UUID.randomUUID().toString()
).createUserAuthentication(agent);
}
示例4: createUserAuthentication
import com.mojang.authlib.UserAuthentication; //导入依赖的package包/类
/**
* Creates a new Mojang user authentication instance using the given proxy.
* @param proxy Proxy to use.
* @return User authentication instance.
*/
public UserAuthentication createUserAuthentication(Proxy proxy);
示例5: getUserAuthentication
import com.mojang.authlib.UserAuthentication; //导入依赖的package包/类
public UserAuthentication getUserAuthentication();