-
-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.20.4 #325
1.20.4 #325
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,9 +49,9 @@ private void updateData() { | |
liv.getActiveStatusEffects().forEach((effect, instance) -> { | ||
String status = lang.get(effect.getTranslationKey()); | ||
if (instance.getAmplifier() != 0) { | ||
status += (String.format(" %d (%s)", instance.getAmplifier()+1, StatusEffectUtil.getDurationText(instance, 1))); | ||
status += (String.format(" %d (%s)", instance.getAmplifier()+1, StatusEffectUtil.getDurationText(instance, 1, 20))); | ||
} else { | ||
status += (String.format(" (%s)", StatusEffectUtil.getDurationText(instance, 1))); | ||
status += (String.format(" (%s)", StatusEffectUtil.getDurationText(instance, 1, 20))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably safe to assume 20 unless we want this to scale on tick warped servers for whatever reason There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its safer to use |
||
} | ||
effectList.add(theme.label(status)).expandX(); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,12 +6,17 @@ | |
import com.google.gson.*; | ||
import com.mojang.authlib.Environment; | ||
import com.mojang.authlib.GameProfile; | ||
import com.mojang.authlib.SignatureState; | ||
import com.mojang.authlib.exceptions.AuthenticationException; | ||
import com.mojang.authlib.minecraft.InsecurePublicKeyException; | ||
import com.mojang.authlib.minecraft.MinecraftProfileTexture; | ||
import com.mojang.authlib.minecraft.MinecraftProfileTextures; | ||
import com.mojang.authlib.properties.Property; | ||
import com.mojang.authlib.yggdrasil.TextureUrlChecker; | ||
import com.mojang.authlib.yggdrasil.ServicesKeyInfo; | ||
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; | ||
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService; | ||
import com.mojang.authlib.yggdrasil.YggdrasilServicesKeyInfo; | ||
import com.mojang.authlib.yggdrasil.response.MinecraftTexturesPayload; | ||
import com.mojang.util.UUIDTypeAdapter; | ||
import meteordevelopment.meteorclient.utils.network.Http; | ||
|
@@ -31,7 +36,7 @@ | |
import static meteordevelopment.meteorclient.MeteorClient.mc; | ||
|
||
public class CustomYggdrasilLogin { | ||
public static Environment localYggdrasilApi = new Environment("/api", "/sessionserver", "/minecraftservices", "Custom-Yggdrasil"); | ||
public static Environment localYggdrasilApi = new Environment("/sessionserver", "/minecraftservices", "Custom-Yggdrasil"); | ||
|
||
public static Session login(String name, String password, String server) throws AuthenticationException { | ||
try { | ||
|
@@ -61,7 +66,7 @@ public static Session login(String name, String password, String server) throws | |
|
||
public static class LocalYggdrasilMinecraftSessionService extends YggdrasilMinecraftSessionService { | ||
private static final Logger LOGGER = LogManager.getLogger(); | ||
private final PublicKey publicKey; | ||
private final ServicesKeyInfo publicKey; | ||
private final Gson gson = new GsonBuilder().registerTypeAdapter(UUID.class, new UUIDTypeAdapter()).create(); | ||
|
||
public LocalYggdrasilMinecraftSessionService(YggdrasilAuthenticationService service, String serverUrl) { | ||
|
@@ -71,50 +76,53 @@ public LocalYggdrasilMinecraftSessionService(YggdrasilAuthenticationService serv | |
this.publicKey = getPublicKey(json.get("signaturePublickey").getAsString()); | ||
} | ||
|
||
private static PublicKey getPublicKey(String key) { | ||
private static ServicesKeyInfo getPublicKey(String key) { | ||
key = key.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", ""); | ||
try { | ||
byte[] byteKey = Base64.getDecoder().decode(key.replace("\n", "")); | ||
X509EncodedKeySpec spec = new X509EncodedKeySpec(byteKey); | ||
KeyFactory factory = KeyFactory.getInstance("RSA"); | ||
return factory.generatePublic(spec); | ||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) { | ||
return YggdrasilServicesKeyInfo.parse(byteKey); | ||
} catch (IllegalArgumentException e) { | ||
e.printStackTrace(); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has changed pretty significantly, but as far as I could tell, the old code was a copy-paste of the base class implementation with the |
||
public Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> getTextures(final GameProfile profile, final boolean requireSecure) { | ||
final Property textureProperty = Iterables.getFirst(profile.getProperties().get("textures"), null); | ||
|
||
if (textureProperty == null) | ||
return new HashMap<>(); | ||
|
||
if (requireSecure) { | ||
if (!textureProperty.hasSignature()) { | ||
LOGGER.error("Signature is missing from textures payload"); | ||
throw new InsecurePublicKeyException("Signature is missing from textures payload"); | ||
} | ||
if (!textureProperty.isSignatureValid(publicKey)) { | ||
LOGGER.error("Textures payload has been tampered with (signature invalid)"); | ||
throw new InsecurePublicKeyException("Textures payload has been tampered with (signature invalid)"); | ||
} | ||
private SignatureState getPropertySignatureState(final Property property) { | ||
if (!property.hasSignature()) { | ||
return SignatureState.UNSIGNED; | ||
} | ||
if (!publicKey.validateProperty(property)) { | ||
return SignatureState.INVALID; | ||
} | ||
return SignatureState.SIGNED; | ||
} | ||
|
||
@Override | ||
public MinecraftProfileTextures unpackTextures(final Property packedTextures) { | ||
final String value = packedTextures.value(); | ||
final SignatureState signatureState = getPropertySignatureState(packedTextures); | ||
|
||
final MinecraftTexturesPayload result; | ||
try { | ||
final String json = new String(org.apache.commons.codec.binary.Base64.decodeBase64(textureProperty.value()), StandardCharsets.UTF_8); | ||
final String json = new String(Base64.getDecoder().decode(value), StandardCharsets.UTF_8); | ||
result = gson.fromJson(json, MinecraftTexturesPayload.class); | ||
} catch (final JsonParseException e) { | ||
} catch (final JsonParseException | IllegalArgumentException e) { | ||
LOGGER.error("Could not decode textures payload", e); | ||
return new HashMap<>(); | ||
return MinecraftProfileTextures.EMPTY; | ||
} | ||
|
||
if (result == null || result.textures() == null || result.textures().isEmpty()) { | ||
return MinecraftProfileTextures.EMPTY; | ||
} | ||
|
||
if (result == null || result.textures() == null) | ||
return new HashMap<>(); | ||
final Map<MinecraftProfileTexture.Type, MinecraftProfileTexture> textures = result.textures(); | ||
|
||
return result.textures(); | ||
return new MinecraftProfileTextures( | ||
textures.get(MinecraftProfileTexture.Type.SKIN), | ||
textures.get(MinecraftProfileTexture.Type.CAPE), | ||
textures.get(MinecraftProfileTexture.Type.ELYTRA), | ||
signatureState | ||
); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what the "correct" loader version to use is, I went with the same version meteor-client is using https://github.com/MeteorDevelopment/meteor-client/blob/master/gradle.properties#L6