mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +03:00
[FIX] Убрано дублирование кода в LauncherConfigurator
This commit is contained in:
parent
709d75eb80
commit
dbc7fa36e7
1 changed files with 25 additions and 18 deletions
|
@ -62,36 +62,33 @@ public String getZipEntryPath() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAddress(String address) {
|
public void setAddress(String address) {
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
setStringField("address", address);
|
||||||
constructor.instructions.add(new LdcInsnNode(address));
|
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "address", stringDesc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProjectName(String name) {
|
public void setProjectName(String name) {
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
setStringField("projectname", name);
|
||||||
constructor.instructions.add(new LdcInsnNode(name));
|
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "projectname", stringDesc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSecretKey(String key) {
|
public void setSecretKey(String key) {
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
setStringField("secretKeyClient", key);
|
||||||
constructor.instructions.add(new LdcInsnNode(key));
|
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "secretKeyClient", stringDesc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOemUnlockKey(String key) {
|
public void setOemUnlockKey(String key) {
|
||||||
|
setStringField("oemUnlockKey", key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setStringField(String name, String value)
|
||||||
|
{
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
constructor.instructions.add(new LdcInsnNode(key));
|
constructor.instructions.add(new LdcInsnNode(value));
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "oemUnlockKey", stringDesc));
|
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, stringDesc));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGuardType(String key) {
|
public void setGuardType(String key) {
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
setStringField("guardType", key);
|
||||||
constructor.instructions.add(new LdcInsnNode(key));
|
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardType", stringDesc));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void push(final int value) {
|
private void push(final int value) {
|
||||||
if (value >= -1 && value <= 5)
|
if (value >= -1 && value <= 5)
|
||||||
constructor.instructions.add(new InsnNode(Opcodes.ICONST_0 + value));
|
constructor.instructions.add(new InsnNode(Opcodes.ICONST_0 + value));
|
||||||
else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE)
|
else if (value >= Byte.MIN_VALUE && value <= Byte.MAX_VALUE)
|
||||||
|
@ -125,15 +122,25 @@ public void setEnv(LauncherConfig.LauncherEnvironment env) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClientPort(int port) {
|
public void setClientPort(int port) {
|
||||||
|
setIntegerField("clientPort", port);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIntegerField(String name, int value)
|
||||||
|
{
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
push(port);
|
push(value);
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "clientPort", Type.INT_TYPE.getInternalName()));
|
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, Type.INT_TYPE.getInternalName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWarningMissArchJava(boolean b) {
|
public void setWarningMissArchJava(boolean b) {
|
||||||
|
setBooleanField("isWarningMissArchJava", b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setBooleanField(String name, boolean b)
|
||||||
|
{
|
||||||
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0));
|
||||||
constructor.instructions.add(new InsnNode(b ? Opcodes.ICONST_1 : Opcodes.ICONST_0));
|
constructor.instructions.add(new InsnNode(b ? Opcodes.ICONST_1 : Opcodes.ICONST_0));
|
||||||
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "isWarningMissArchJava", Type.BOOLEAN_TYPE.getInternalName()));
|
constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, Type.BOOLEAN_TYPE.getInternalName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGuardLicense(String name, String key, String encryptKey) {
|
public void setGuardLicense(String name, String key, String encryptKey) {
|
||||||
|
|
Loading…
Reference in a new issue