Skip to content

Commit

Permalink
Merge pull request zlainsama#3 from microwin7/fix
Browse files Browse the repository at this point in the history
Additional fix
  • Loading branch information
microwin7 authored Feb 2, 2023
2 parents 23605d8 + ca32fb4 commit b4a5bdf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/main/java/lain/mods/skins/impl/MojangService.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ else if (code / 100 == 2)
GameProfile constructed = gson.fromJson(buf.toString(), GameProfile.class);
if (!constructed.isComplete()) // why does the server return an incomplete profile? treat it as not found.
return Shared.DUMMY;
if (Shared.isOfflinePlayer(constructed.getId(), constructed.getName())) // why does the server return an offline profile? treat it as not found.
return Shared.DUMMY;
// if (Shared.isOfflinePlayer(constructed.getId(), constructed.getName())) // why does the server return an offline profile? treat it as not found.
// return Shared.DUMMY;
return new GameProfile(constructed.getId(), constructed.getName()); // reconstruct it because default JsonDeserializer doesn't construct a GameProfile properly, can't use GameProfileSerializer because it's a private class.
}
}
Expand Down
76 changes: 38 additions & 38 deletions src/main/java/lain/mods/skins/impl/PlayerProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,44 +53,44 @@ public void onSuccess(GameProfile filled)
}, Runnable::run);
}
}
else if (Shared.isOfflinePlayer(key.getId(), key.getName())) // an offline profile that needs resolving
{
Futures.addCallback(MojangService.getProfile(key.getName()), new FutureCallback<GameProfile>() // resolve it
{

@Override
public void onFailure(Throwable t)
{
}

@Override
public void onSuccess(GameProfile resolved)
{
if (resolved == Shared.DUMMY) // failed
return;
profile.set(resolved);

Futures.addCallback(MojangService.fillProfile(resolved), new FutureCallback<GameProfile>() // fill it
{

@Override
public void onFailure(Throwable t)
{
}

@Override
public void onSuccess(GameProfile filled)
{
if (filled == resolved) // failed or already filled
return;
profile.set(filled);
}

}, Runnable::run);
}

}, Runnable::run);
}
// else if (Shared.isOfflinePlayer(key.getId(), key.getName())) // an offline profile that needs resolving
// {
// Futures.addCallback(MojangService.getProfile(key.getName()), new FutureCallback<GameProfile>() // resolve it
// {
//
// @Override
// public void onFailure(Throwable t)
// {
// }
//
// @Override
// public void onSuccess(GameProfile resolved)
// {
// if (resolved == Shared.DUMMY) // failed
// return;
// profile.set(resolved);
//
// Futures.addCallback(MojangService.fillProfile(resolved), new FutureCallback<GameProfile>() // fill it
// {
//
// @Override
// public void onFailure(Throwable t)
// {
// }
//
// @Override
// public void onSuccess(GameProfile filled)
// {
// if (filled == resolved) // failed or already filled
// return;
// profile.set(filled);
// }
//
// }, Runnable::run);
// }
//
// }, Runnable::run);
// }
else if (key.getProperties().isEmpty()) // an assumed online profile that needs filling
{
Futures.addCallback(MojangService.fillProfile(key), new FutureCallback<GameProfile>() // fill it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ISkin getSkin(IPlayerProfile profile)
if (_filter != null)
skin.setSkinFilter(_filter);
SharedPool.execute(() -> {
//if (!Shared.isOfflinePlayer(profile.getPlayerID(), profile.getPlayerName())) {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = MinecraftUtils.getSessionService().getTextures((GameProfile) profile.getOriginal(), false);
if (textures != null && textures.containsKey(MinecraftProfileTexture.Type.CAPE))
{
Expand All @@ -35,6 +36,7 @@ public ISkin getSkin(IPlayerProfile profile)
skin.put(data, "cape");
});
}
//}
});
return skin;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ISkin getSkin(IPlayerProfile profile)
if (_filter != null)
skin.setSkinFilter(_filter);
SharedPool.execute(() -> {
//if (!Shared.isOfflinePlayer(profile.getPlayerID(), profile.getPlayerName())) {
Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = MinecraftUtils.getSessionService().getTextures((GameProfile) profile.getOriginal(), false);
if (textures != null && textures.containsKey(MinecraftProfileTexture.Type.SKIN))
{
Expand All @@ -35,6 +36,7 @@ public ISkin getSkin(IPlayerProfile profile)
skin.put(data, SkinData.getSkinType(tex));
});
}
//}
});
return skin;
}
Expand Down

0 comments on commit b4a5bdf

Please sign in to comment.