修改:     HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/utils/auth/SkinmeAuthenticator.java
	修改:     HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N.properties
	修改:     HMCLAPI/src/main/resources/org/jackhuang/hellominecraft/launcher/I18N_zh_CN.properties
	修改:     README.md
This commit is contained in:
huanghongxun 2015-12-17 18:13:30 +08:00
commit d3372e6a60
4 changed files with 52 additions and 53 deletions

View File

@ -18,7 +18,6 @@
package org.jackhuang.hellominecraft.launcher.utils.auth; package org.jackhuang.hellominecraft.launcher.utils.auth;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.code.DigestUtils; import org.jackhuang.hellominecraft.utils.code.DigestUtils;
import org.jackhuang.hellominecraft.utils.NetUtils; import org.jackhuang.hellominecraft.utils.NetUtils;
import org.jackhuang.hellominecraft.views.Selector; import org.jackhuang.hellominecraft.views.Selector;
@ -39,15 +38,14 @@ public final class SkinmeAuthenticator extends IAuthenticator {
public String getCharacter(String user, String hash, String $char) throws Exception { public String getCharacter(String user, String hash, String $char) throws Exception {
return NetUtils.get( return NetUtils.get(
"http://www.skinme.cc/api/login.php?user=" + user + "&hash=" + hash + (($char == null) ? "" : ("&char=" + $char))); "http://www.skinme.cc/api/login.php?user=" + user + "&hash=" + hash + (($char == null) ? "" : ("&char=" + $char)));
} }
@Override @Override
public UserProfileProvider login(LoginInfo info) throws AuthenticationException { public UserProfileProvider login(LoginInfo info) throws AuthenticationException {
UserProfileProvider req = new UserProfileProvider(); UserProfileProvider req = new UserProfileProvider();
if (info.username == null || !info.username.contains("@")) { if (info.username == null || !info.username.contains("@"))
throw new AuthenticationException(C.i18n("login.not_email")); throw new AuthenticationException(C.i18n("login.not_email"));
}
try { try {
String usr = info.username.toLowerCase(); String usr = info.username.toLowerCase();
String pwd = info.password; String pwd = info.password;
@ -58,45 +56,45 @@ public final class SkinmeAuthenticator extends IAuthenticator {
String[] sl = data.split(":"); String[] sl = data.split(":");
if (null != sl[0]) if (null != sl[0])
switch (sl[0]) { switch (sl[0]) {
case "0": case "0":
if (sl[1].contains("No Valid Character")) if (sl[1].contains("No Valid Character"))
sl[1] = C.i18n("login.no_valid_character"); sl[1] = C.i18n("login.no_valid_character");
throw new AuthenticationException(sl[1]); throw new AuthenticationException(sl[1]);
case "1": { case "1": {
String[] s = parseType1(sl[1]); String[] s = parseType1(sl[1]);
req.setUserName(s[0]); req.setUserName(s[0]);
req.setSession(s[1]); req.setSession(s[1]);
req.setUserId(s[1]); req.setUserId(s[1]);
req.setAccessToken(s[1]); req.setAccessToken(s[1]);
break; break;
}
case "2": {
String[] charators = sl[1].split(";");
int len = charators.length;
String[] $char = new String[len];
String[] user = new String[len];
System.out.println(sl[1]);
for (int i = 0; i < len; i++) {
String[] charator = charators[i].split(",");
$char[i] = charator[0];
user[i] = charator[1];
} }
case "2": { Selector s = new Selector(null, user, C.i18n("login.choose_charactor"));
String[] charators = sl[1].split(";"); s.setVisible(true);
int len = charators.length; if (s.sel == Selector.FAILED_TO_SELECT)
String[] $char = new String[len]; throw new AuthenticationException(C.i18n("message.cancelled"));
String[] user = new String[len]; else {
System.out.println(sl[1]); int index = s.sel;
for (int i = 0; i < len; i++) { String character = $char[index];
String[] charator = charators[i].split(","); sl = getCharacter(usr, hashCode, character).split(":");
$char[i] = charator[0]; String[] s2 = parseType1(sl[1]);
user[i] = charator[1]; req.setUserName(s2[0]);
} req.setSession(s2[1]);
Selector s = new Selector(null, user, C.i18n("login.choose_charactor")); req.setUserId(s2[1]);
s.setVisible(true); req.setAccessToken(s2[1]);
if (s.sel == Selector.failedToSel) {
throw new AuthenticationException(C.i18n("message.cancelled"));
} else {
int index = s.sel;
String character = $char[index];
sl = getCharacter(usr, hashCode, character).split(":");
String[] s2 = parseType1(sl[1]);
req.setUserName(s2[0]);
req.setSession(s2[1]);
req.setUserId(s2[1]);
req.setAccessToken(s2[1]);
}
break;
} }
break;
}
} }
req.setUserType("Legacy"); req.setUserType("Legacy");

View File

@ -1,3 +1,4 @@
<<<<<<< HEAD
# Hello Minecraft! Launcher. # Hello Minecraft! Launcher.
# Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com> # Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
# #

View File

@ -1,6 +1,6 @@
# Hello Minecraft! Launcher # Hello Minecraft! Launcher
Hello Minecraft! Launcher is a Minecraft launcher. Hello Minecraft! Launcher is a Minecraft launcher.
License is GPL v3, see http://www.gnu.org/licenses/. License is GPL v3, see http://www.gnu.org/licenses/gpl.html
### Joining ### Joining
If you really want to join the development, here's some requests. If you really want to join the development, here's some requests.