Skip to content

Commit

Permalink
Add SkinProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
Lassebq committed Jan 11, 2025
1 parent a2876a9 commit 5add2b9
Show file tree
Hide file tree
Showing 23 changed files with 908 additions and 764 deletions.
8 changes: 4 additions & 4 deletions src/main/java/org/mcphackers/launchwrapper/LaunchConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.Map;
import java.util.regex.Pattern;

import org.mcphackers.launchwrapper.protocol.SkinOption;
import org.mcphackers.launchwrapper.protocol.SkinRequests;
import org.mcphackers.launchwrapper.protocol.SkinType;
import org.mcphackers.launchwrapper.protocol.skin.MojangSkinProvider;
import org.mcphackers.launchwrapper.protocol.skin.SkinOption;
import org.mcphackers.launchwrapper.protocol.skin.SkinType;
import org.mcphackers.launchwrapper.util.OS;

@SuppressWarnings("unused")
Expand Down Expand Up @@ -156,7 +156,7 @@ public LaunchConfig(String[] args) {
}
if (uuid.get() == null && username.get() != null) {
// Resolve profile UUID if we only provide username
uuid.set(SkinRequests.getUUIDfromName(username.get()));
uuid.set(MojangSkinProvider.getUUIDfromName(username.get()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ private InputStream getIndex(final boolean xml) throws IOException {
if (xml) {
s.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>");
s.append("<ListBucketResult>");
}
for (AssetObject asset : assets.list()) {
// path,size,last_updated_timestamp(unused)
if (xml) {
for (AssetObject asset : assets.list()) {
s.append("<Contents>");
s.append("<Key>");
s.append(asset.path);
Expand All @@ -40,12 +37,12 @@ private InputStream getIndex(final boolean xml) throws IOException {
s.append(Long.toString(asset.size));
s.append("</Size>");
s.append("</Contents>");
} else {
s.append(asset.path + ',' + asset.size + ",0\n");
}
}
if (xml) {
s.append("</ListBucketResult>");
} else {
for (AssetObject asset : assets.list()) {
s.append(asset.path + ',' + asset.size + ",0\n");
}
}
return new ByteArrayInputStream(s.toString().getBytes());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.net.URLConnection;

import org.mcphackers.launchwrapper.LaunchConfig;
import org.mcphackers.launchwrapper.protocol.skin.SkinRequests;

public class LegacyURLStreamHandler extends URLStreamHandlerProxy {

Expand All @@ -17,7 +18,7 @@ public class LegacyURLStreamHandler extends URLStreamHandlerProxy {
public LegacyURLStreamHandler(LaunchConfig config) {
this.config = config;
this.assets = new AssetRequests(config.assetsDir.get(), config.assetIndex.get());
this.skins = new SkinRequests(config.gameDir.get(), config.skinOptions.get(), config.skinProxy.get());
this.skins = new SkinRequests(config.gameDir.get(), config.assetsDir.get(), config.skinOptions.get(), config.skinProxy.get());
this.levelSaveDir = config.levelsDir.get();
}

Expand Down Expand Up @@ -83,17 +84,18 @@ protected URLConnection openConnection(URL url) throws IOException {
// return new BasicResponseURLConnection(url, "1");
}
// FIXME server sends their own skin as packet
if (host.equals("textures.minecraft.net")) {
if (path.startsWith("/texture/")) {
return new TextureURLConnection(url, skins);
}
}
}
if (host.equals("sessionserver.mojang.com")) {
if (path.startsWith("/session/minecraft/profile/")) {
return new ProfileURLConnection(url, skins);
}
// TODO rewrite as injection instead of redirecting URL
// if (host.equals("textures.minecraft.net")) {
// if (path.startsWith("/texture/")) {
// return new TextureURLConnection(url, skins);
// }
// }
}
// if (host.equals("sessionserver.mojang.com")) {
// if (path.startsWith("/session/minecraft/profile/")) {
// return new ProfileURLConnection(url, skins);
// }
// }
return openDirectConnection(url);
}
}

This file was deleted.

Loading

0 comments on commit 5add2b9

Please sign in to comment.