From dbc7fa36e7bcf87a07383c938b96fe00ef93e8c2 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 5 Sep 2019 19:25:53 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=A3=D0=B1=D1=80=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B4=D1=83=D0=B1=D0=BB=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4=D0=B0=20=D0=B2=20LauncherConf?= =?UTF-8?q?igurator?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../binary/LauncherConfigurator.java | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java index 818ed953..56b5e6c8 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/LauncherConfigurator.java @@ -62,36 +62,33 @@ public String getZipEntryPath() { } public void setAddress(String address) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(address)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "address", stringDesc)); + setStringField("address", address); } public void setProjectName(String name) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(name)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "projectname", stringDesc)); + setStringField("projectname", name); } public void setSecretKey(String key) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(key)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "secretKeyClient", stringDesc)); + setStringField("secretKeyClient", 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 LdcInsnNode(key)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "oemUnlockKey", stringDesc)); + constructor.instructions.add(new LdcInsnNode(value)); + constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, stringDesc)); } public void setGuardType(String key) { - constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - constructor.instructions.add(new LdcInsnNode(key)); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "guardType", stringDesc)); + setStringField("guardType", key); } - public void push(final int value) { + private void push(final int value) { if (value >= -1 && value <= 5) constructor.instructions.add(new InsnNode(Opcodes.ICONST_0 + 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) { + setIntegerField("clientPort", port); + } + + public void setIntegerField(String name, int value) + { constructor.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - push(port); - constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, "clientPort", Type.INT_TYPE.getInternalName())); + push(value); + constructor.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, autoGenConfigName, name, Type.INT_TYPE.getInternalName())); } 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 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) {