Refactor code

This commit is contained in:
GeorgH93 2019-07-14 19:44:05 +02:00
parent 38a9463016
commit 5f8a5d37e4
No known key found for this signature in database
GPG Key ID: D1630D37F9E4B3C8
3 changed files with 12 additions and 4 deletions

View File

@ -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();
}
}

View File

@ -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()

View File

@ -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.