File tree Expand file tree Collapse file tree
src/main/java/org/mcphackers/launchwrapper/loader Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .mcphackers .launchwrapper .loader ;
22
3- import static org .objectweb .asm .ClassWriter .COMPUTE_FRAMES ;
4- import static org .objectweb .asm .ClassWriter .COMPUTE_MAXS ;
3+ import static org .objectweb .asm .ClassWriter .*;
54
65import java .io .ByteArrayInputStream ;
7- import java .io .FileNotFoundException ;
86import java .io .IOException ;
97import java .io .InputStream ;
108import java .net .URL ;
@@ -35,13 +33,14 @@ public void connect() throws IOException {
3533 @ Override
3634 public InputStream getInputStream () throws IOException {
3735 String path = url .getPath ();
38- byte [] data = classLoader .overridenResources .get (LaunchClassLoader . classNameFromResource ( path ) );
36+ byte [] data = classLoader .overridenResources .get (path );
3937 if (data != null ) {
4038 return new ByteArrayInputStream (data );
4139 }
42- ClassNode node = classLoader .overridenClasses .get (path );
40+ ClassNode node = classLoader .overridenClasses .get (LaunchClassLoader . classNameFromResource ( path ) );
4341 if (node == null ) {
44- throw new FileNotFoundException ();
42+ InputStream is = classLoader .getOriginalURL (path ).openStream ();
43+ return is ;
4544 }
4645 ClassWriter writer = new SafeClassWriter (classLoader , COMPUTE_MAXS | COMPUTE_FRAMES );
4746 node .accept (writer );
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ public URL findResource(String resource) {
144144 return getOriginalURL (resource );
145145 }
146146
147- private URL getOriginalURL (String resource ) {
147+ URL getOriginalURL (String resource ) {
148148 URL url = urlClassLoader .findResource (resource );
149149 if (url != null ) {
150150 return url ;
@@ -164,7 +164,7 @@ private URL getOverridenResourceURL(String resource) {
164164 originalUrl .getProtocol (),
165165 originalUrl .getHost (),
166166 originalUrl .getPort (),
167- originalUrl . getFile () ,
167+ resource ,
168168 new ClassLoaderURLHandler (this ));
169169 }
170170 } catch (MalformedURLException ignored ) {
@@ -497,9 +497,9 @@ public static String classResourceName(String name) {
497497
498498 public static String classNameFromResource (String resource ) {
499499 if (resource .endsWith (".class" )) {
500- return resource .substring (0 , resource .length () - 6 );
500+ return resource .substring (0 , resource .length () - 6 ). replace ( '/' , '.' ) ;
501501 }
502- return resource ;
502+ return null ;
503503 }
504504
505505 public static LaunchClassLoader instantiate () {
You can’t perform that action at this time.
0 commit comments