mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FIX] Paper installAuthlib
This commit is contained in:
parent
df04b459be
commit
c74f430129
2 changed files with 30 additions and 0 deletions
|
@ -20,6 +20,7 @@ public class InstallAuthlib {
|
||||||
modifierMap.put("META-INF/libraries.list", new LibrariesLstModifier());
|
modifierMap.put("META-INF/libraries.list", new LibrariesLstModifier());
|
||||||
modifierMap.put("patch.properties", new PatchPropertiesModifier());
|
modifierMap.put("patch.properties", new PatchPropertiesModifier());
|
||||||
modifierMap.put("META-INF/download-context", new DownloadContextModifier());
|
modifierMap.put("META-INF/download-context", new DownloadContextModifier());
|
||||||
|
modifierMap.put("META-INF/patches.list", new PatchesLstModifier());
|
||||||
}
|
}
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
boolean deleteAuthlibAfterInstall = false;
|
boolean deleteAuthlibAfterInstall = false;
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package pro.gravit.launcher.server.authlib;
|
||||||
|
|
||||||
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
import pro.gravit.utils.helper.SecurityHelper;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
|
||||||
|
public class PatchesLstModifier implements LibrariesHashFileModifier {
|
||||||
|
@Override
|
||||||
|
public byte[] apply(byte[] data, InstallAuthlib.InstallAuthlibContext context) throws IOException {
|
||||||
|
String[] lines = new String(data).split("\n");
|
||||||
|
for(int i=0;i<lines.length;++i) {
|
||||||
|
if(lines[i].contains("paper-")) {
|
||||||
|
String[] separated = lines[i].split("\t");
|
||||||
|
Path path = context.workdir.resolve("versions").resolve(separated[6]);
|
||||||
|
if(Files.notExists(path)) {
|
||||||
|
LogHelper.warning("Unable to find %s. Maybe you should start the server at least once?", path);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
separated[3] = SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256, path));
|
||||||
|
lines[i] = String.join("\t", separated);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.join("\n", lines).getBytes(StandardCharsets.UTF_8);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue