mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] byte[] в конфиге.
This commit is contained in:
parent
96d8883ecb
commit
fd23ba555b
1 changed files with 13 additions and 0 deletions
|
@ -1,5 +1,7 @@
|
|||
package pro.gravit.launchserver.asm;
|
||||
|
||||
import java.util.Base64;
|
||||
|
||||
import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
import org.objectweb.asm.Type;
|
||||
|
@ -14,6 +16,8 @@
|
|||
|
||||
public class ConfigGenerator {
|
||||
protected static final String stringDesc = Type.getDescriptor(String.class);
|
||||
protected static final String byteArrDesc = Type.getDescriptor(byte[].class);
|
||||
protected static final String base64DecDesc = "(" + stringDesc + ")" + byteArrDesc;
|
||||
protected final ClassNode configclass;
|
||||
protected final MethodNode constructor;
|
||||
|
||||
|
@ -43,6 +47,15 @@ public void setStringField(String name, String value)
|
|||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, stringDesc));
|
||||
}
|
||||
|
||||
public void setByteArrayField(String name, byte[] value)
|
||||
{
|
||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/Base64", "getDecoder", "()Ljava/util/Base64$Decoder;", false));
|
||||
constructor.instructions.add(NodeUtils.getSafeStringInsnList(Base64.getEncoder().encodeToString(value)));
|
||||
constructor.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "java/util/Base64$Decoder", "decode", base64DecDesc, false));
|
||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, configclass.name, name, stringDesc));
|
||||
}
|
||||
|
||||
public void setIntegerField(String name, int value)
|
||||
{
|
||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||
|
|
Loading…
Reference in a new issue