From 8ab1dda430b4c4af45331faa1cddda09afbb3c08 Mon Sep 17 00:00:00 2001
From: Gravita <gravita@gravit.pro>
Date: Fri, 30 Apr 2021 00:39:25 +0700
Subject: [PATCH] [FIX] Double ProGuard task

---
 .../launchserver/components/ProGuardComponent.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java
index dfac3098..b65cb4bb 100644
--- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java
+++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java
@@ -28,16 +28,22 @@ public class ProGuardComponent extends Component implements AutoCloseable, Recon
     public boolean enabled = true;
     public boolean mappings = true;
     public transient ProguardConf proguardConf;
+    private transient LaunchServer launchServer;
+    private transient ProGuardBuildTask buildTask;
     private transient static final Logger logger = LogManager.getLogger();
     @Override
     public void init(LaunchServer launchServer) {
+        this.launchServer = launchServer;
         proguardConf = new ProguardConf(launchServer, this);
-        launchServer.launcherBinary.addAfter((v) -> v.getName().startsWith(modeAfter), new ProGuardBuildTask(launchServer, proguardConf, this));
+        this.buildTask = new ProGuardBuildTask(launchServer, proguardConf, this);
+        launchServer.launcherBinary.addAfter((v) -> v.getName().startsWith(modeAfter), buildTask);
     }
 
     @Override
     public void close() throws Exception {
-
+        if(launchServer != null && buildTask != null) {
+            launchServer.launcherBinary.tasks.remove(buildTask);
+        }
     }
 
     @Override