From 5f8a5d37e4f89a3bab0807e6b6b666161e8dc77d Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sun, 14 Jul 2019 19:44:05 +0200 Subject: [PATCH] Refactor code --- .../Minepacks/Bukkit/ItemsCollector.java | 11 +++++++++-- src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java | 3 ++- test/src/.keep | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/ItemsCollector.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/ItemsCollector.java index 511249d..caa43b3 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/ItemsCollector.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/ItemsCollector.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016-2018 GeorgH93 + * Copyright (C) 2019 GeorgH93 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,6 +25,7 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.scheduler.BukkitRunnable; +import org.bukkit.scheduler.BukkitTask; import java.util.HashMap; import java.util.List; @@ -33,12 +34,13 @@ public class ItemsCollector extends BukkitRunnable { private final Minepacks plugin; private final double radius; + private final BukkitTask task; public ItemsCollector(Minepacks plugin) { this.plugin = plugin; this.radius = plugin.getConfiguration().getFullInvRadius(); - runTaskTimer(plugin, plugin.getConfiguration().getFullInvCheckInterval(), plugin.getConfiguration().getFullInvCheckInterval()); + task = runTaskTimer(plugin, plugin.getConfiguration().getFullInvCheckInterval(), plugin.getConfiguration().getFullInvCheckInterval()); } @Override @@ -79,4 +81,9 @@ public void run() } } } + + public void close() + { + task.cancel(); + } } \ No newline at end of file diff --git a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java index e934152..a3b5342 100644 --- a/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java +++ b/src/at/pcgamingfreaks/Minepacks/Bukkit/Minepacks.java @@ -200,13 +200,14 @@ private void load() private void unload() { + if(collector != null) collector.close(); commandManager.close(); if(collector != null) collector.cancel(); if(database != null) database.close(); // Close the DB connection, we won't need them any longer HandlerList.unregisterAll(this); // Stop the listeners - getServer().getScheduler().cancelTasks(this); // Kill all running task if(cooldownManager != null) cooldownManager.close(); cooldownManager = null; + getServer().getScheduler().cancelTasks(this); // Kill all running task } public void reload() diff --git a/test/src/.keep b/test/src/.keep index 3182c8a..0962353 100644 --- a/test/src/.keep +++ b/test/src/.keep @@ -1,2 +1,2 @@ -The munge-maven-plugin requiers a test source folder. +The munge-maven-plugin requires a test source folder. There currently are no tests so this file is here instead. \ No newline at end of file