mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-06 08:39:33 +00:00
[FEATURE] Added String array reader, to display in Reflection GUI
This commit is contained in:
@@ -5,6 +5,7 @@ import org.parabot.core.asm.ASMClassLoader;
|
|||||||
import org.parabot.core.classpath.ClassPath;
|
import org.parabot.core.classpath.ClassPath;
|
||||||
import org.parabot.core.reflect.RefClass;
|
import org.parabot.core.reflect.RefClass;
|
||||||
import org.parabot.core.reflect.RefField;
|
import org.parabot.core.reflect.RefField;
|
||||||
|
import org.parabot.environment.api.utils.StringUtils;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionEvent;
|
||||||
@@ -91,6 +92,8 @@ public class ReflectUI extends JFrame {
|
|||||||
result = f;
|
result = f;
|
||||||
} else if (value.toLowerCase().endsWith(search.toLowerCase())) {
|
} else if (value.toLowerCase().endsWith(search.toLowerCase())) {
|
||||||
result = f;
|
result = f;
|
||||||
|
} else if (value.toLowerCase().contains(search.toLowerCase())){
|
||||||
|
result = f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -238,6 +241,13 @@ public class ReflectUI extends JFrame {
|
|||||||
builder.append("<b>Type: </b>").append(refField.getASMType().getClassName()).append("<br/>");
|
builder.append("<b>Type: </b>").append(refField.getASMType().getClassName()).append("<br/>");
|
||||||
builder.append("<b>Static: </b>").append(refField.isStatic() ? "yes" : "no").append("<br/>");
|
builder.append("<b>Static: </b>").append(refField.isStatic() ? "yes" : "no").append("<br/>");
|
||||||
builder.append("<b>Array: </b>").append(refField.isArray() ? refField.getArrayDimensions() + " dimension(s)" : "no").append("<br/>");
|
builder.append("<b>Array: </b>").append(refField.isArray() ? refField.getArrayDimensions() + " dimension(s)" : "no").append("<br/>");
|
||||||
|
|
||||||
|
if (refField.isArray() && refField.getASMType().getClassName().contains("String") && refField.getArrayDimensions() == 1){
|
||||||
|
String[] strings = (String[]) refField.asObject();
|
||||||
|
String values = StringUtils.implode(", ", strings);
|
||||||
|
|
||||||
|
builder.append("<b>Values: </b>").append(values).append("<br/>");
|
||||||
|
}
|
||||||
selectionInfoPane.setText(builder.toString());
|
selectionInfoPane.setText(builder.toString());
|
||||||
|
|
||||||
fillBasicInfoPane();
|
fillBasicInfoPane();
|
||||||
|
|||||||
@@ -28,6 +28,19 @@ public class StringUtils {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String implode(String separator, String... data) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < data.length - 1; i++) {
|
||||||
|
//data.length - 1 => to not add separator at the end
|
||||||
|
if (!data[i].matches(" *")) {//empty string are ""; " "; " "; and so on
|
||||||
|
sb.append(data[i]);
|
||||||
|
sb.append(separator);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sb.append(data[data.length - 1].trim());
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public static String randomString(final int length) {
|
public static String randomString(final int length) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < 20; i++) {
|
for (int i = 0; i < 20; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user