public MultiplayerMenu() {
Game.ISONLINE = true;
Game.ISHOST = false;
if(savedUUID == null) savedUUID = "";
if(email == null) email = "";
if(savedUsername == null) savedUsername = "";
// HTTP REQUEST - determine if there is internet connectivity.
//String url = "https://www.playminicraft.com"; // test request
setWaitMessage("testing connection");
Unirest.get(domain).asBinaryAsync(new Callback<InputStream>() {
@Override
public void completed(HttpResponse<InputStream> httpResponse) {
if(httpResponse.getStatus() == 200)
online = true;
else
System.out.println("warning: minicraft site ping returned status code " + httpResponse.getStatus());
//if(Game.getMenu() != MultiplayerMenu.this) return; // don't continue if the player moved to a different menu.
if(savedUUID.length() > 0) {
// there is a previous login that can be used; check that it's valid
setWaitMessage("attempting log in");
//if (Game.debug) System.out.println("fetching username for uuid");
fetchName(savedUUID);
}
if(curState == State.ERROR)
return;
// at this point, the game is online, and either the player could log in automatically, or has to enter their
// email and password.
if(savedUsername.length() == 0 || savedUUID.length() == 0)
curState = State.LOGIN; // the player must log in manually.
else {
typing = savedIP;
curState = State.ENTERIP; // the user has sufficient credentials; skip login phase
}
}
@Override
public void failed(UnirestException e) {
e.printStackTrace();
cancelled();
}
@Override
public void cancelled() {
if(savedUsername.length() == 0 || savedUUID.length() == 0) {
// couldn't validate username, and can't enter offline mode b/c there is no username
setError("no internet connection, but no login data saved; cannot enter offline mode.", false);
//setError("could not access "+url);
return;
}
// there is a saved copy of the uuid and username of the last player; use it for offline mode.
curState = State.ENTERIP;
}
});
}
MultiplayerMenu.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:minicraft-plus-revived
作者:
评论列表
文章目录