mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-16 00:47:27 +02:00
Cleanup for all added components, reorder cleanup on disable.
This commit is contained in:
parent
9bd7745690
commit
53756f7145
@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -244,6 +245,9 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
private boolean manageListeners = true;
|
||||
|
||||
protected final List<PermStateReceiver> permStateReceivers = new ArrayList<PermStateReceiver>();
|
||||
|
||||
/** All registered components. */
|
||||
protected Set<Object> allComponents = new LinkedHashSet<Object>(50);
|
||||
|
||||
protected Metrics metrics = null;
|
||||
|
||||
@ -252,6 +256,7 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
*/
|
||||
@Override
|
||||
public void addComponent(final Object obj) {
|
||||
allComponents.add(obj);
|
||||
if (obj instanceof Listener) {
|
||||
addListener((Listener) obj);
|
||||
}
|
||||
@ -363,6 +368,22 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Stop all remaining tasks...");
|
||||
getServer().getScheduler().cancelTasks(this);
|
||||
|
||||
// Exemptions cleanup.
|
||||
NCPExemptionManager.clear();
|
||||
|
||||
// Data cleanup.
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup DataManager...");
|
||||
dataMan.onDisable();
|
||||
|
||||
// Hooks:
|
||||
// (Expect external plugins to unregister their hooks on their own.)
|
||||
// (No native hooks present, yet.)
|
||||
|
||||
// Unregister all added components explicitly.
|
||||
for (Object obj : allComponents){
|
||||
removeComponent(obj);
|
||||
}
|
||||
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup some mappings...");
|
||||
// Remove listeners.
|
||||
listeners.clear();
|
||||
@ -371,17 +392,6 @@ public class NoCheatPlus extends JavaPlugin implements NoCheatPlusAPI {
|
||||
// World specific permissions.
|
||||
permStateReceivers.clear();
|
||||
|
||||
// Data cleanup.
|
||||
if (verbose) LogUtil.logInfo("[NoCheatPlus] Cleanup DataManager...");
|
||||
dataMan.onDisable();
|
||||
|
||||
// Exemptions cleanup.
|
||||
NCPExemptionManager.clear();
|
||||
|
||||
// Hooks:
|
||||
// (Expect external plugins to unregister their hooks on their own.)
|
||||
// (No native hooks present, yet.)
|
||||
|
||||
// Clear command changes list (compatibility issues with NPCs, leads to recalculation of perms).
|
||||
if (changedCommands != null){
|
||||
changedCommands.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user