Skip to content

Commit

Permalink
implement onDisable and actually disable things in it even
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 8, 2021
1 parent 0cde1e5 commit f504c72
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -14,7 +14,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<BUILD_NUMBER>Unknown</BUILD_NUMBER>
<bukkit.version>1.16.4-R0.1-SNAPSHOT</bukkit.version>
<bukkit.version>1.16.5-R0.1-SNAPSHOT</bukkit.version>
<denizen.version>1.1.9-SNAPSHOT</denizen.version>
</properties>

Expand Down Expand Up @@ -87,7 +87,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/denizenscript/ddiscordbot/DenizenDiscordBot.java
Expand Up @@ -12,6 +12,8 @@
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.utilities.debugging.FutureWarning;
import com.denizenscript.denizencore.utilities.debugging.Warning;
import org.bukkit.Bukkit;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.HashMap;
Expand Down Expand Up @@ -173,4 +175,21 @@ public void onEnable() {
Debug.echoError(ex);
}
}

@Override
public void onDisable() {
for (DiscordConnection connection : connections.values()) {
try {
if (connection.client != null) {
connection.client.shutdownNow();
}
}
catch (Throwable ex) {
Debug.echoError(ex);
}
}
connections.clear();
Bukkit.getServer().getScheduler().cancelTasks(this);
HandlerList.unregisterAll(this);
}
}

0 comments on commit f504c72

Please sign in to comment.