@@ -155,6 +155,21 @@ public static ClassNode getCurrentlyOpenedClassNode() {
155155 return viewer .workPane .getCurrentViewer ().cn ;
156156 }
157157
158+ public static FileContainer findContainer (String containerName , String fileName ) {
159+ boolean checkContainer = !containerName .endsWith (".class" );
160+ System .out .println ("Loading " + containerName + "$" + fileName );
161+ for (FileContainer container : files ) {
162+ if (checkContainer && !container .name .equals (containerName ))
163+ continue ;
164+ if (container .getData ().containsKey (fileName )) {
165+ System .out .println ("Found it" );
166+ return container ;
167+ }
168+ }
169+
170+ return null ;
171+ }
172+
158173 /**
159174 * Returns the ClassNode by the specified name
160175 *
@@ -163,14 +178,27 @@ public static ClassNode getCurrentlyOpenedClassNode() {
163178 * @return the ClassNode instance
164179 */
165180 public static ClassNode getClassNode (String containerName , String name ) {
166- for (FileContainer container : files ) {
167- String classFileName = name + ".class" ;
168- if (container .name .equals (containerName ) && container .getData ().containsKey (classFileName )) {
169- return container .getClassNode (classFileName );
170- }
171- }
181+ String classFileName = name + ".class" ;
182+ FileContainer container = findContainer (containerName , classFileName );
183+ if (container != null )
184+ return container .getClassNode (classFileName );
185+ else
186+ return null ;
187+ }
172188
173- return null ;
189+ public static byte [] getFileBytes (String containerName , String name ) {
190+ FileContainer container = findContainer (containerName , name );
191+ if (container != null )
192+ return container .getData ().get (name );
193+ else
194+ return null ;
195+ }
196+
197+ public static byte [] getClassBytes (String containerName , ClassNode cn ) {
198+ byte [] bytes = getFileBytes (containerName , getClassfileName (cn ));
199+ if (cn .version < 49 )
200+ bytes = fixBytes (bytes );
201+ return bytes ;
174202 }
175203
176204 public static final String HACK_PREFIX = "\0 JDA-hack" ;
@@ -183,22 +211,6 @@ public static File getClassFileProxy(InnerClassNode cn) {
183211 return new File ('/' + HACK_PREFIX , cn .name + ".class" );
184212 }
185213
186- public static byte [] getFileBytes (String containerName , String name ) {
187- for (FileContainer container : files ) {
188- if (container .name .equals (containerName ) && container .getData ().containsKey (name )) {
189- return container .getData ().get (name );
190- }
191- }
192- return null ;
193- }
194-
195- public static byte [] getClassBytes (String containerName , ClassNode cn ) {
196- byte [] bytes = getFileBytes (containerName , getClassfileName (cn ));
197- if (cn .version < 49 )
198- bytes = fixBytes (bytes );
199- return bytes ;
200- }
201-
202214 public static String getClassfileName (ClassNode cn ) {
203215 return cn .name + ".class" ;
204216 }
0 commit comments