This commit is contained in:
fullwall 2014-09-15 15:17:48 +08:00
parent 7e5c0d8e24
commit e035ffde04

View File

@ -124,8 +124,8 @@ public class HumanController extends AbstractEntityController {
private GameProfile fillProfileProperties(YggdrasilAuthenticationService auth, GameProfile profile, private GameProfile fillProfileProperties(YggdrasilAuthenticationService auth, GameProfile profile,
boolean requireSecure) throws Exception { boolean requireSecure) throws Exception {
URL url = HttpAuthenticationService.constantURL(new StringBuilder() URL url = HttpAuthenticationService.constantURL(new StringBuilder()
.append("https://sessionserver.mojang.com/session/minecraft/profile/") .append("https://sessionserver.mojang.com/session/minecraft/profile/")
.append(UUIDTypeAdapter.fromUUID(profile.getId())).toString()); .append(UUIDTypeAdapter.fromUUID(profile.getId())).toString());
url = HttpAuthenticationService.concatenateURL(url, url = HttpAuthenticationService.concatenateURL(url,
new StringBuilder().append("unsigned=").append(!requireSecure).toString()); new StringBuilder().append("unsigned=").append(!requireSecure).toString());
MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke( MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse) MAKE_REQUEST.invoke(
@ -152,7 +152,7 @@ public class HumanController extends AbstractEntityController {
if (cached != null) { if (cached != null) {
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging Messaging
.debug("Using cached skin texture for NPC " + npc.getName() + " UUID " + npc.getUniqueId()); .debug("Using cached skin texture for NPC " + npc.getName() + " UUID " + npc.getUniqueId());
} }
skinProfile = new GameProfile(UUID.fromString(realUUID), ""); skinProfile = new GameProfile(UUID.fromString(realUUID), "");
skinProfile.getProperties().put("textures", cached); skinProfile.getProperties().put("textures", cached);
@ -164,7 +164,7 @@ public class HumanController extends AbstractEntityController {
} catch (Exception e) { } catch (Exception e) {
if ((e.getMessage() != null && e.getMessage().contains("too many requests")) if ((e.getMessage() != null && e.getMessage().contains("too many requests"))
|| (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage() || (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage()
.contains("too many requests"))) { .contains("too many requests"))) {
SKIN_THREAD.delay(); SKIN_THREAD.delay();
SKIN_THREAD.addRunnable(this); SKIN_THREAD.addRunnable(this);
} }
@ -243,6 +243,8 @@ public class HumanController extends AbstractEntityController {
public String call() throws Exception { public String call() throws Exception {
String skinUUID = UUID_CACHE.get(reportedUUID); String skinUUID = UUID_CACHE.get(reportedUUID);
if (skinUUID != null) { if (skinUUID != null) {
npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, skinUUID);
npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, reportedUUID);
reportedUUID = skinUUID; reportedUUID = skinUUID;
} }
if (reportedUUID.contains("-")) { if (reportedUUID.contains("-")) {
@ -252,22 +254,22 @@ public class HumanController extends AbstractEntityController {
.getGameProfileRepository(); .getGameProfileRepository();
repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT, repo.findProfilesByNames(new String[] { ChatColor.stripColor(reportedUUID) }, Agent.MINECRAFT,
new ProfileLookupCallback() { new ProfileLookupCallback() {
@Override @Override
public void onProfileLookupFailed(GameProfile arg0, Exception arg1) { public void onProfileLookupFailed(GameProfile arg0, Exception arg1) {
throw new RuntimeException(arg1); throw new RuntimeException(arg1);
} }
@Override @Override
public void onProfileLookupSucceeded(final GameProfile profile) { public void onProfileLookupSucceeded(final GameProfile profile) {
UUID_CACHE.put(reportedUUID, profile.getId().toString()); UUID_CACHE.put(reportedUUID, profile.getId().toString());
if (Messaging.isDebugging()) { if (Messaging.isDebugging()) {
Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName() Messaging.debug("Fetched UUID " + profile.getId() + " for NPC " + npc.getName()
+ " UUID " + npc.getUniqueId()); + " UUID " + npc.getUniqueId());
} }
npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString()); npc.data().setPersistent(CACHED_SKIN_UUID_METADATA, profile.getId().toString());
npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName()); npc.data().setPersistent(CACHED_SKIN_UUID_NAME_METADATA, profile.getName());
} }
}); });
return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID); return npc.data().get(CACHED_SKIN_UUID_METADATA, reportedUUID);
} }
} }