mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +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;
|
package pro.gravit.launchserver.asm;
|
||||||
|
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
import org.objectweb.asm.ClassWriter;
|
import org.objectweb.asm.ClassWriter;
|
||||||
import org.objectweb.asm.Opcodes;
|
import org.objectweb.asm.Opcodes;
|
||||||
import org.objectweb.asm.Type;
|
import org.objectweb.asm.Type;
|
||||||
|
@ -14,6 +16,8 @@
|
||||||
|
|
||||||
public class ConfigGenerator {
|
public class ConfigGenerator {
|
||||||
protected static final String stringDesc = Type.getDescriptor(String.class);
|
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 ClassNode configclass;
|
||||||
protected final MethodNode constructor;
|
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));
|
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)
|
public void setIntegerField(String name, int value)
|
||||||
{
|
{
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
|
|
Loading…
Reference in a new issue